I am working on a tower defense game involving a tower shooting an enemy, but when the tower shoots, it shoots the bullet forward in the world direction instead of on its rotation. The bullet doesn’t go forward towards the enemy but goes forward in world space off screen.
I am using the following code to shoot the bullet from the tower script,
var ball = Instantiate(bullet, spawnPoint.transform.position, transform.localRotation);
ball.rigidbody.AddForce(ball.transform.localPosition.forward * 5000);
bullet is a GameoObject
spawnPoint is a Transform
Is there a new way to shoot something on its local forward axis? Was the .forward script changed recently, because most of the gun scripts are using it but it doesn’t work for me now. How do I fix the problem and shoot it forward.