Script to transform shots in the instance spaceship direction

Hi, I want to change mover script of space shooter tutorials in a way that every shot continues in the instance spaceship direction and not just “forward” the blue axis direction. I suppose it should be changes on transform class script.

public class Mover : MonoBehaviour {

public float speed;
void Start ()
{
GetComponent ().velocity = transform.forward * speed;
}
}

Thanks, Mohsen

You could parent you shot instance to space ship, that way shot will continue to always move toward from space ship. But you didn’t describe clearly what effect you are after.

Actually, I manipulated the script for player of the tutorial as below:
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis (“Horizontal”);
float moveVertical = Input.GetAxis (“Vertical”);
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

    GetComponent<Rigidbody>().velocity = movement * speed;
GetComponent<Rigidbody>().position = new Vector3
		(
	Mathf.Clamp (GetComponent<Rigidbody>().position.x, boundary.xMin, boundary.xMax), 
	0.0f, 
	Mathf.Clamp (GetComponent<Rigidbody>().position.z, boundary.zMin, boundary.zMax)
		);

GetComponent().rotation = Quaternion.Euler (GetComponent().velocity.z * -tiltFront, GetComponent().velocity.x * rotateYaxis, GetComponent().velocity.x * -tilt);
}
The last phrase is where I did my manipulations, I added the front tilt and Y axis rotation. as you said having the shots under spaceship continues the direction, it worked, but new problem, I don’t want the shots to leave the game plane ( they do when in movement the spaceship points out of X-Z plane.