player rotating on z axis but not moving forward in z axis ?


public class Boundry{

public float minX,maxX;

public class movements : MonoBehaviour {

public float z_speed = 10.0f;

public float x_Speed;

public float tilt;

public Boundry boundrys;

Rigidbody body;

void Update (){

void FixedUpdate (){
	body = GetComponent<Rigidbody> ();
	float movehorizontal = Input.GetAxis ("Horizontal");
	Vector3 movement = new Vector3 (movehorizontal, 0,0);
	body.velocity = movement * x_Speed;
	body.position = newVector3(Mathf.Clamp(body.position.x,boundrys.minX,boundrys.maxX),0,0);
	body.rotation = Quaternion.Euler(0,0,body.velocity.x * -tilt);


am using this script from spaceship tutorial but am having a problem with moving forward on z-axis continuously. I want my player to go in a forward direction on the z-axis continuously and also rotate on z-axis for tilt effect but unfortunately, I can’t move forward am just stuck in one place and am just a beginner in scripting so pls help me out with this problem

Try adding:

float moveVertical = Input.GetAxis("Vertical");

and then make your Vector3 movement:

Vector3 movement = new Vector3 (moveHorizontal, 0, moveVertical);

you may also have to add Mathf.Clamps for the Z axis so you don’t fly off the top and bottom of the screeen.