# Match local axis with direction

So here I have a surface , an icosphere , with a player , the cube , and the destination , the red line pointing upwards over the other side. To reach the destination I am pushing the player forward , however to reach the destination I would have to rotate the LOCAL y of the player to face the red line.

This is the result I would need to achieve for the player to reach the destination by moving forward. However since my vector maths is quite terrible , I don’t know where to go from here , how would I calculate the angle and rotate the player only on it’s local y axis?

Maybe this thread helps? Running around small planets.

only two solutions come to my mind so far.
first one : make your cube child of an emptyGameObject, move that empty gameobject as usual movement, also add rigidbody to empty game object, and write something like this.

``````   CubeObject.transform.rotation = Quaternion.Lerp(CubeObject.transform.rotation,Quaternion.LookRotation(-emptyGameObjsRigidbody.velocity),5);

or maybe:

CubeObject.transform.LookAt(ParentEmptyGameObj.transform.TransformVector(Vector3.forward));
``````

its hard to suggest a solution with no information about your project, scripts etc.

second one :

project two lines (red and blue ones) onto a plane. and find theirs intercept point (its simple vector math, not that hard you can do it) and rotate your cube towards that intercept point.

normaly , i would go for second one…