I was following the space shooter tutorial on unity3d.com step by step and everything was fine until i got to the enemy ship evasive maneuver script, I am a beginner so i had some difficulty understanding the script but i decided to copy it anyway. When i ran the game the enemy ships spawned in my position (the position of the player at the beginning of the game) and when i delete the script everything works fine without the enemy ships moving around. I am sure there are no syntax errors since i copied the script directly from the unity site. I would really appreciate some help fixing this problem. One thing i think may have something to do with this is that before adding the enemy ships when making the instantiate function for the hazards quaternion.identity didnt work (asteroids would spawn in wrong rotation and move in the wrong direction) so i used new quaternion(90,90,90,90) and it worked for them.
Hey, this just happened to me too and I noticed that no one had solved this for you yet. Make sure that you didn’t mix up the rb.position.z in the second Mathf.Clamp. It should look like this. This fixed it for me.
Mathf.Clamp (rb.position.x, boundary.xMin, boundary.xMax ), 0.0f, Mathf.Clamp ( rb.position.z, boundary.zMin, boundary.zMax )