pPos = GameObject.FindGameObjectWithTag (“Player”).transform.position;
foreach (GameObject s in eSpawn.eSnake)
{
if (bFireRate >= 0.75f)
{
Rigidbody bullet = Instantiate(eAi.Bullet, s.transform.position,
Quaternion.LookRotation((pPos - s.transform.position))) as Rigidbody;
bFireRate = 0.0f;
}
}
}
So the above script works.
Whats odd is that the below script doesn’t:
pPos = eAi.Player.transform.position;
foreach (GameObject s in eSpawn.eSnake)
{
if (bFireRate >= 0.75f)
{
Rigidbody bullet = Instantiate(eAi.Bullet, s.transform.position,
Quaternion.LookRotation((pPos - s.transform.position))) as Rigidbody;
bFireRate = 0.0f;
}
}
}
Isn’t it the same thing?
The eAi script is attached to a Main empty object in the world, which is then attached to a Empty object that is the child of the object that fires the bullet.
I use the child Empty object as a Sphere collier. Which contains the script that fires the bullet.