Adding a spaceship's speed and direction to Bullet speed

Hi. I’ve been looking for weeks now for Answers or tutorials on this and never come across a solution.

It’s easy to instantiate a bullet at the position/rotation of the firer (in my case, a spaceship in a top down 2D game) and to give the bullet its own speed in the world. The problem is that if you fire forward and are travelling fast, you can overtake your bullet, or at least perceive it to be travelling more slowly than if you spun around and fired backwards behind you (while you were heading “forwards” still).

This is because you’re moving with or away from the bullet but the bullet is always at a constant ‘world’ speed.

How do I get the bullet to take into account the player’s speed (with the appropriate direction) when it’s fired, and add it to the bullet’s rigidbody.velocity? This would allow shots in any direction and at any speed behave properly and look as though they all have the same speed relative to the player’s position.

I don’t want to use raycasting as dodging the bullets is a mechanic.

Thanks - Kevin

Your source code would be helpful for an accurate answer. If you are setting the movement of the bullet by assigning a velocity, simply add the velocity of the ship to the initial velocity of the bullet. If you are using AddForce(). Set the velocity of the bullet to the velocity of the ship before doing AddForce().

  bullet.velocity = ship.velocity + bullet.forward * speed;

Or:

 bullet.velocity = ship.velocity;
 bullet.AddForce(bullet.forward * amount);

This was an issue I had with 4.6 when I posted this, but I’m not sure if 5.0 still has it. I think it does.
I actually passed it just through the arguments.

void OnEnable (GameObject theFirer)
	{		}

and

obj1.SendMessage ("OnEnable", theFirer);

The console throws the error but it doesn’t stop playing or building and the code works. I wasn’t happy about leaving that code in my wake and moving on with the constant error forever in my console, but it’s the best I ever got with it.