- Home /
Ball Rolling Animation Not Working Properly
For my game, I was trying to achieve ball rolling animation something like this based on finger movement.
At present, I got success in rolling ball in forwarding direction through right vector rotation so it's looking like we are moving in forwarding direction.
Now based on finger drag, I want to turn the ball on the left and right rotation based on the required measure so I have turned on forward vector rotation but can't able to generate smooth looking rotation in left and right drag.
 public class BallMeshRolling : MonoBehaviour
 {
     private Vector3 ballLastPosition;
 
 
     void Start ()
     {
         ballLastPosition = transform.parent.position;
     }
 
     void Update ()
     {
 
         // ball moving forward animation
         float rollingSpeed = Vector3.Distance (transform.parent.position, ballLastPosition) * 30f;
         transform.RotateAround (transform.position, Vector3.right, rollingSpeed);
 
         // ball moving left & right animation
         float dragDifference = (transform.position.x - ballLastPosition.x) * 30f;
         transform.RotateAround (transform.position, Vector3.forward, dragDifference);
 
         ballLastPosition = transform.parent.position;
     }
 }
As per above code, forward animation running proper but left and right drag rolling animation not working properly so I want some improvements in that.
Your answer
 
 
             Follow this Question
Related Questions
Rotating an object towards target on a single axis 2 Answers
How do i rotate based on direction character is moving in 1 Answer
Get the rotation of a object around a arbitrary axis. 0 Answers
How to get Angle float of specific axis.(Turret clamping related). 2 Answers
Why is this rotation acting odd? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                