Greetings!
I am a relatively new Unity user and very new to scripting. I have found a lot of great scripting tutorials but there is one thing in particular that I want to do. I want to develop an iOS game and one of the things I need to do is manipulate the gravity such that as the iOS device is rotated, gravity appears to tilt in the opposite the direction or, from a real-life perspective, gravity continues to draw objects in the game down even though the game level is being rotated by the rotation of the device. If this doesn’t make any sense, it is probably so much easier to understand when you see an example. Here is one from Youtube: - YouTube
I thought I found the perfect code (displayed in the Youtube video above) but then I found that it was script for Corona SDK. Darn it!!
So, I was wondering if anyone, such as someone who has worked with both Unity and Corona, knows how to translate the code I found on Youtube (found below) into Unity Javascript (preferable) or C# (which would be great to).
Here is the code:
function onTilt(event)
physics.setGravity( ( 10 * event.xGravity), (-10 * event.yGravity) )
end
Runtine.addEventListener(“accelerometer”, onTilt)
I would appreciate any help you can give me. Thanks so much!
Dwayne
The Chicken Reborn