Question by
cagdassalur · Sep 20, 2015 at 10:33 AM ·
transformdirection
Can't get transformdirection to work properly
I'm making a simple rolling marble game and i have a problem with movement. User can rotate the camera around the marble at 90 degree increments. When i move the marble left or right its working properly but when i move the marble away from the camera it slows down, and when i move the marble close the camera it speeds up.
I'm using this to translate keyboard input to ball movement in respect to camera's direction;
controlDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
ball_rb.AddForce(transform.TransformDirection(controlDirection)*forceMultiplier);
when i Debug.Log(transform.TransformDirection(controlDirection));
when moving horizontally i get (1, 0, 0) and (-1, 0, 0) which is expected but when i move vertically i get (-0.9, -0.5, 0) and (0.9, 0.5, 0)
What am i doing wrong?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612034406im_/https://answers.unity.com/themes/thub/images/avi.jpg)