proper velocity - always in front of player!

My goal: to have the missle spawn in front of the player each time (traveling at very high speeds) with the proper velocity so the missle always spawns in front of the player and with the correct force.

I’m kind of redoing my question from eariler. I just want to get this working. In an FPS game, I inherit the velocity of the player

instantiatedProjectile1.rigidbody.velocity = this.transform.parent.parent.rigidbody.velocity;

But then I get stuck here. I don’t actually want the velocity of the player, because that means the velocity of the rigidbody follows it (e.g., if I’m falling down the bullet falls down when aiming up). This is what I’m using in the missle:

initialSpeed = transform.TransformDirection  (Vector3(0,0,300))

This “works” when aiming, but since it is a constant velocity it stays behind when the player is moving at high speeds. Adding a forward force does help, but it’s still based off the player velocity and therefore is very inaccurate. Maybe some sort of AddForce mixed with a transformDirection? Any help is appreciated.

You just need to add them together.

transform.TransformDirection (Vector3(0,0,300)) is the same as transform.forward*300. So your projectile’s velocity should look like:

instantiatedProjectile1.rigidbody.velocity = transform.root.rigidbody.velocity + transform.forward*300;