I'm just wanting to do something simple like hold the iphone sideways and roll the ball depending on where I tilt the iphone. There is a roll a ball tutorial or resource but the controls are completely backwards for it. I tilt forward and it rolls backward.
This is what I want:
I want to tilt the iphone and the ball gains momentum as I continue to tilt the phone.
Bounce off of the walls that I put in it.
I know this is very simple but I'm pretty new to everything since I switched from torque script so help convert me over to unity :D
Here is the code I'm using:
public var force:float = 1.0;
public var simulateAccelerometer:boolean = false;
function Start()
{
iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape;
}
function FixedUpdate () {
var dir : Vector3 = Vector3.zero;
if (simulateAccelerometer)
{
dir.x = Input.GetAxis("Horizontal");
dir.z = Input.GetAxis("Vertical");
}
else
{
dir.x = -iPhoneInput.acceleration.y;
dir.z = iPhoneInput.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize();
}
rigidbody.AddForce(dir * force);
}