How to stop prefabs instantiating at random locations
I have a "Gun" that has a "GunEnd" where the bullets fire out of. For some strange reason the bullets fire at three different locations all at random, at one point it'll come out of the "GunEnd" but sometimes it instantiates at random along the Y axis. I've tried different ways off instantiating but nothing works.
I don't think this is the problem, but it might be worth testing it: you should add the force to the bullet inside FixedUpdate(), not Update() - physics calculations should always be done in FixedUpdate. Also, check the location and print it out before applying the force.
Thank you I'll give it a go and see if it helps
Thank you very much it has worked like a charm!
Answer by Piyush_Pandey · May 04, 2017 at 07:15 AM
Check your gun.transform.position
by logging. If that is changing in Y axis too then the bullet's position will definitely change in Y.
Also use Quaternion.Identity
instead of gun.transform.locaEulerangles