When i start the game the rocket changes its rotation from 0,0,270 to 0,0,0

What to do?

following is my player movement script due to which the rotation is changing. Some one please help me to figure out the problem:

using UnityEngine;
using System.Collections;

[System.Serializable]
public class Boundary
	
{
	public float yMin, yMax, zMin, zMax;
	
}

public class Player_Controller : MonoBehaviour 

{
	public float speed;
	public float tilt;
	public Boundary boundary;
	
	void FixedUpdate ()
	{
		float moveHorizontal= Input.GetAxis ("Horizontal");
		float moveVertical= Input.GetAxis ("Vertical");
		
		Vector3 movement = new Vector3 (0.0f, moveVertical, moveHorizontal);
		rigidbody.velocity = movement * speed;
		
		rigidbody.position = new Vector3
			(
				0.0f,
				Mathf.Clamp (rigidbody.position.y, boundary.yMin, boundary.yMax),
				Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax)
				
				);
		rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.y * -tilt);
		
	}
}

And also i wanted the rotate the prefabs of the fire coming from the rocket

On every physics step, you’re setting the rotation to be Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.y * -tilt). So rigidbody.velocity.y * -tilt is evaluating to 0. So consider what might make that happen:

  • tilt is declared but never initialised. What is its value in the inspector?

  • rigidbody.velocity = movement * speed. speed, like tilt is declared but not initialised. What is its value?

  • And finally the y component of movement is set based on the “moveVertical” axis. Unless you’re applying some input to this axis, it too will be zero.

If any of these three variables are zero, your rotation will be zero.