# How to make a jump and a rotation using javascript?

Hello, I am a rookie in unity i was trying to make a moving car, I am using the following command in javascript to make it “jump n rotate” but the movement is irregular and sometimes it even ends up piercing right through my terrain please help!Am i writing something wrong ??

if (Input.GetKey (KeyCode.Space) ) {
transform. Rotate ( rotation_speedTime.deltaTime, 0.00 , rotation_speedTime.deltaTime);
transform.Translate (Vector3 (0.00, 3.00,0.00)
Time.deltaTime*5.00); }
*

You’ve not explained much about your project, but since you write “piercing right through my terrain,” I’m guessing you have a Rigidbody. Typically Rigidbodies need to be moved through force, not transform.Translate() and transform.Rotate(). For exmaple:

``````rigidbody.AddForce(Vector3.up*upForce*Time.deltaTime);
``````

Note how much force you need will depend on the mass of the object. If your car does not seem to move, greatly increase upForce and angularForce.

If instead you have a character controller, take a look at CharacterController.Move() and CharacterController.MoveSimple().

Thank you for your answer robertbu i tried using your commands and it really helped !! I used rigidbody for gravity. What i don’t get is why in the video that i used as tutorial the source code was the same as mine and its car was moving perfectly while mine is trembling and if i increese my speed it pierces the terrain.
My project is not much just a cube with four cylinders attached under it moving on a larger cube and i followed all the steps in the video in the end i only had to change a bit the numbers in my source code to fix the movement a bit. This is my source code

``````pragma strict
public var forward_speed  : int = 5;
public var backward_speed : int = 5;
public var rotation_speed : int = 80;
function Start () {

}

static var speed : int = 5;

function Update () {

if (Input.GetKey (KeyCode.UpArrow)) transform.Translate (Vector3(1,-0.5,-0.55) * Time.deltaTime*forward_speed);
if (Input.GetKey (KeyCode.DownArrow)) transform.Translate (Vector3(-1,-0.005,0.5) * Time.deltaTime*backward_speed);
if (Input.GetKey (KeyCode.LeftArrow)) transform.Rotate  (0.0 , -rotation_speed * Time.deltaTime , 0.0 );
if (Input.GetKey (KeyCode.RightArrow)) transform.Rotate (0.0 , rotation_speed * Time.deltaTime , 0.0 );
if (Input.GetKey (KeyCode.Space) ) { rigidbody.AddTorque (Vector3.up* angularForce* Time.deltaTime);
rigidbody.AddForce ( Vector3.up * upForce *Time.deltaTime); }

}
``````