- Home /
Trouble Spawning Bullets with proper rotation
I'm finding rotations pretty confusing at the moment so I'm sure I've made a simple mistake somewhere but I could definitely use an extra pair of eyes on what's going on. I appreciate the help.
I'm trying to spawn bullets for a shotgun weapon in my games AI, the shotgun has 3 fire points from which I'm trying to spawn a bullet. The firepoints are set up like this 1st fires bullet straight at the nearest enemy with no extra rotation, 2nd firepoint is rotated 10° and the 3rd is rotated -10°.
In the end what I want to happen is to have is a shotgun like spread where the three bullets move from the gun and differ slightly in their paths.
However when the gun fires, only the first bullet goes towards it's target properly, the other two always head towards some global position and never rotate with the character. Here is my code for instantiating the bullets.
Instantiate(projectile, firepoint.transform.position, Quaternion.LookRotation(bulletTrajectory+firepoint.transform.localEulerAngles)