How do i move the object in my game to tie right by clicking the right arrow key ?

This is the script now:

using UnityEngine;

public class Player : MonoBehaviour
{
//double movSpeed=3.0;
//Input mov = Input.GetAxis(“Vertical”) * Time.deltaTime * movSpeed;

void Update ()
{

//transform.Translate(Vector3(0,0,mov));
//if (Input.GetKey (KeyCode.RightArrow)) {
transform.Translate(Vector3.forward * Time.deltaTime);
//rigidbody2D.transform.Translate (Vector3.forward * Time.deltaTime);
//}*/
}
}

I tried also the other things in the code but nothing is working in all cases i tried the object is keep falling down when i click the play button in unity.

If the object has a rigidbody then it uses Unity’s physics engine (ie. gravity is applied). This would cause the object to fall every time you start the game. You can turn off the physics by checking the “is kinematic” property on the rigidbody.

1 Like