# Moving forward based on rotation

Hello everyone!
I am trying to make script where character should be able to jump over an object. I have this code, it works, but it is a little buggy, sometimes it goes in wrong direction, or rotation x changes, but sometimes it works just like it should. I think that the problem is with degrees/radians, since I don’t know a lot about them…

GameObject “Igrac” has Mouse look script attached, with rotation around x (y rotation coord changes). I want to make character to move in front direction (where camera is pointing) and make 2 “meters” in that diretion. Here is my code:

``````#pragma strict
var newX : float;
var newZ : float;
var angle : float;
var angle1 : float;
var x : float;
var z : float;
var y : float;

function JumpOver()
{

angle = transform.eulerAngles.y;
angle1 = GameObject.Find("Igrac").transform.rotation.x;
x = GameObject.Find("Igrac").transform.localPosition.x;
y = GameObject.Find("Igrac").transform.localPosition.y;
z = GameObject.Find("Igrac").transform.localPosition.z;

newX = x + 2*Mathf.Sin(angle * (180/Mathf.PI));
newZ = z + 2*Mathf.Cos(angle * (180/Mathf.PI));

iTween.RotateTo(GameObject.Find("Igrac"),Vector3(0,angle,30),1);
iTween.MoveTo(GameObject.Find("Igrac"),Vector3(newX,y+1,newZ),1);
Invoke("JumpOverEnd", 0.4);
}

function JumpOverEnd()
{
iTween.RotateTo(GameObject.Find("Igrac"),Vector3(0,angle,0),1);
iTween.MoveTo(GameObject.Find("Igrac"),Vector3(newX,y,newZ),1);
}
``````

Also, I am using iTween library, but it works just like transform.position and transform.rotation, just smooths a little bit…

Solved this. Problem was that I had to enter radians to use Mathf.Sin , instead of degrees.