Hello!

I am trying to get a “gun” object that fires a “bullet” object in a sine wave pattern.

The gun can be pointing in any direction, so to get the bullet to travel forward I use this:

`transform.Translate(Vector3.forward * magnitude * Time.deltaTime);`

I want the bullet to always be facing the direction that is moving (always forward), so it’s forward direction will rotate as it is moving forward to follow the path of the sine wave. To do this, I think I should rotate the transform. I’ve tried several ways with no success.

For my last try I did the following:

`Vector3 direction = transform.Forward; direction.x += Cos(transform.position.x); direction.y += Sin(transform.position.x); direction.Normalize(); transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(direction), Time.deltaTime);`

Then I move it forward using the code I supplied up top, but the bullets just sort of bubble around facing silly directions.

I’ve made so many changes that I don’t think the above even makes sense anymore.

Can someone help me with the math for this?

Thanks!