- Home /
Question by
Vignesh_Droid · Mar 02, 2013 at 11:30 AM ·
ballroll
How to roll a ball?
I am trying to make a ball rotate on floor with a touch joystick.Every time I try to roll the ball the local coordinates roll too! So when I add force,the ball gets stuck when z coordinate is pependicular to the floor so I cant move because I added force alond z coordinate.
Comment
Best Answer
Answer by Meater6 · Mar 03, 2013 at 08:23 AM
Add force in the global xz plane (or torque if you want) and then modify with the camera's rotation like so:
var dir : Vector3 = Vector3(h, 0, v);
var cameraY : Quaternion = Quaternion.Euler(0, cameraTransform.rotation.eulerAngles.y, 0);
dir.y = 0;
dir = Vector3.Normalize(dir);
dir = cameraY * dir;
Your answer
![](https://koobas.hobune.stream/wayback/20220613093656im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
iphone roll a ball game 2 Answers
A node in a childnode? 1 Answer
make a wedge moveable 0 Answers
Curve a Ball in 3d space 4 Answers
Ball Z-Axis Rolling 1 Answer