I dont mean its position in the array i mean the possition of part of the array in the scene.
im making a snake game so i need it to be, hits the food → destroys the food → instantiates a tail piece → makes the joint conect to the tailpart befor it —> creates a new pice of food.
how would i wright it tho for a object in the array? i need to find the position of the last object in an array. this is were i get the error var tailpos = tail[tail.length ].position but becase position isent a member of Object it dosent work? var tailpos = tail[tail.length ].transform.position dosent work eather becase transform isent a member of Object
this is the code that affects this:
var tailsegment : GameObject;
var tail = new Array ();
function OnCollisionEnter(collision : Collision)
{
tail.length = tail.length ++;
var tailpos = tail[tail.length -1].position;//problem hear
Instantiate(tailsegment,tailpos, Quaternion.identity);
tailsegment.CharicterJoint.connectedBody = tail[tail.length]; //other problems hear
tail [tail.length] == tailsegment;
}