- Home /
Question by
cr99999999 · May 22, 2013 at 06:08 AM ·
gameobjectjumpingreturn
Why is my object jumping to 0,0,0 coordinates?
Object seems to work fine unless I use the following function to return an object. Then it throws my object at 0,0,0 position? After searching for a possible solution I found that people seem to have a similar problem with animated objects. My object is animated but like I said, it only jumps to 0,0,0 when I use this function.
GameObject _getTarget()
{
if (_team==1){_enemyAll=dynamicMesh._teamAall;}
if (_team==2){_enemyAll=dynamicMesh._teamBall;}
if (_team==3){_enemyAll=dynamicMesh._teamCall;}
if (_team==4){_enemyAll=dynamicMesh._teamDall;}
GameObject enemy;
enemy=_enemyAll[0];
{
float thisDist;
float enemyDist;
enemy=_enemyAll[_enemyAll.Count-1];
enemyDist = Vector3.Distance (transform.position,enemy.transform.position);
for(int i = 0; i < _enemyAll.Count; i++)
{
thisDist = Vector3.Distance (transform.position,_enemyAll[i].transform.position);
if (thisDist<enemyDist)
{enemy=_enemyAll[i];enemyDist = Vector3.Distance (transform.position,enemy.transform.position);}
}
}
return enemy;
}
Comment
Which object is thrown to 0,0,0? Also, can you debug it and find after which line of code it happens?
Your answer
