- Home /
Question by
CallToAdventure · Jul 15, 2011 at 09:09 PM ·
gravityaccelerometer
Accelerometer based gravity
I am trying to figure out how to change the gravity in my scene based on the device orientation. Anybody got some tips/ideas/links?
Thanks!
Comment
Answer by aldonaletto · Jul 16, 2011 at 02:56 AM
Character controllers may have weird reactions to non-conventional gravity (out of -Y direction), but you can affect all rigidbodies changing physics gravity with the accelerometer:
function FixedUpdate(){
Physics.gravity = 9.8 * Input.acceleration.normalized;
}
Maybe you have to change the acceleration signal - I'm not sure if Input.acceleration returns negative acceleration for gravity as it should.
Hi
Physics.gravity = 9.8 * Input.acceleration.normalized;
work fine I want to rotate my object according to the inclination of device
any help
Your answer
