I have an enemy in my game who (as you’d expect) shoots at me if I’m in range. I have a gun attached to the enemy model, and a script which instantiates a projectile at the end of it(using a bulletSpawn empty GameObject). The problem is, as part of the shooting animation the gun isn’t facing directly at me.
How can I instantiate the bullet in the direction of the player?
var direction = enemy.transform.position - projectileStartPosition;
var projectile = (Transform)Instantiate(projectilePrefab, projectileStartPosition, Quaternion.LookRotation(direction));