Quantcast
Channel: Questions in topic: "get"
Viewing all articles
Browse latest Browse all 215

How to get objects with a specific component and store them in an array.

$
0
0
So, i made this code to switch weapons, and all i'm trying to do is get how much weapons the player has, so i know how to set the array, and then, put all weapons into the array, however, how do i get the objects with the "WeaponFire" component? BTW, this is not an FPS, nor a TPS, it is a car combat game. Code: #pragma strict var currentWeapon = 0; var Weapons : WeaponFire[]; function getSelectedWeapon() : WeaponFire { return Weapons[currentWeapon]; } function Start() { if (currentWeapon >= Weapons.length) currentWeapon = Weapons.length-1; for (var i=0; i= Weapons.length) currentWeapon = 0; SelectWeapon(Weapons[currentWeapon]); } function DisableWeapon(Weapon : WeaponFire) { Weapon.weaponSelected = false; } function SelectWeapon(Weapon : WeaponFire) { Weapon.weaponSelected = true; }

Viewing all articles
Browse latest Browse all 215

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>