I’ve been trying to make a shooting game where a load of boxes get knocked off of a pedestal, and a target comes down to shoot after wards. This is what I have so far.
var cubeTag;
var heightToCheck : float = 0.9f;
var target:Rigidbody;
var cubeArray = new Array ();
cubeArray.length = 18;
cubeArray.Push(GameObject.FindWithTag("cubeTag"));
cubeArray.Push(GameObject.FindWithTag("cubeTag1"));
cubeArray.Push(GameObject.FindWithTag("cubeTag2"));
cubeArray.Push(GameObject.FindWithTag("cubeTag3"));
cubeArray.Push(GameObject.FindWithTag("cubeTag4"));
cubeArray.Push(GameObject.FindWithTag("cubeTag5"));
cubeArray.Push(GameObject.FindWithTag("cubeTag6"));
cubeArray.Push(GameObject.FindWithTag("cubeTag7"));
cubeArray.Push(GameObject.FindWithTag("cubeTag8"));
cubeArray.Push(GameObject.FindWithTag("cubeTag9"));
cubeArray.Push(GameObject.FindWithTag("cubeTag10"));
cubeArray.Push(GameObject.FindWithTag("cubeTag11"));
cubeArray.Push(GameObject.FindWithTag("cubeTag12"));
cubeArray.Push(GameObject.FindWithTag("cubeTag13"));
cubeArray.Push(GameObject.FindWithTag("cubeTag14"));
cubeArray.Push(GameObject.FindWithTag("cubeTag15"));
cubeArray.Push(GameObject.FindWithTag("cubeTag16"));
cubeArray.Push(GameObject.FindWithTag("cubeTag17"));
for (var i = 0; i<cubeArray.length; i++)
{
var currentElementBeingTested = cubeArray*;*
-
//do something with currentElementBeingTested*
-
Debug.Log("cube array y position = "+currentElementBeingTested.Transform.transform.position.y);*
- }*
function CheckForCubeHeight(){ //This function is to check to see if the cube has fallen off of the pedestal.
- var cubeToCheck = GameObject.FindWithTag(“cubeTag2”);*
- //var cubeToCheck = cubeArray[0];*
- //Debug.Log("reading cube as "+cubeToCheck);*
- //Debug.Log("cubeToCheck “+cubeToCheck.transform.position.y +”> Height is "+heightToCheck);*
- if(cubeToCheck.transform.position.y < heightToCheck){*
-
Debug.Log("cube on floor. Reading y as "+cubeToCheck.transform.position.y);*
-
///target.velocity = transform.TransformDirection (Vector3(0,1,0));*
- }*
}
function Update () {
- CheckForCubeHeight();*
}