- Home /
Question by
siddharth3322 · Jan 24, 2016 at 05:35 PM ·
unity 5physics3dgravityaccelerometer
Move ball object based on gravity
I want to move my ball object based on gravity and gravity I am changing based on device rotation. But I can't able to get desire control in movement as well some sort of jerk in ball movement as well.
At present I am using this code for moving ball object :
public class GolfBall : MonoBehaviour
{
private Rigidbody myRigidbody;
private Vector3 force = Vector3.zero;
//
public float power;
void Awake ()
{
myRigidbody = GetComponent<Rigidbody> ();
}
void Update ()
{
Vector3 accel = Input.acceleration;
accel.z *= -1f;
Physics.gravity = accel * power;
}
}
I want to move my ball as like this video suggest. Golf Globe Challenge for the iPhone/iPod
Please give me some kind of help to move ball object smoothly as well desire. If you need any more information to give suggestion in then ask me anytime for it.
Comment
Please someone give me guidance in this.
Unity 3D realistic accelerometer control
But didn't able to get actual output that exist in video.