I have written a script to control my character and i can choose whether to use the accelerometer or touch to control. What i want to do for the touch is when you hold down your finger on the phone the player will continue to go up and when you release the gravity will cause it to come back down. right now when you touch the player will go up and stay up when you release. Do i use Touch Phases? How do I do this? Thanks
var Speed : float;
var ForwardSpeed : float;
var UseAccelerometer : boolean;
var UseTouch : boolean;
var Sensitivity : float;
function FixedUpdate ()
{
//PC Testing Control
var pc_z : float = Input.GetAxis ("Vertical");
var computerMovement : Vector3 = Vector3(0, pc_z * Sensitivity, 0);
rigidbody.AddForce(computerMovement * Time.fixedDeltaTime * Speed);
//iPhone Accelerometer Control
if (UseAccelerometer)
{
var mobile_z : float = Input.acceleration.x;
var accelMovement : Vector3 = Vector3(0, mobile_z * Sensitivity, 0);
rigidbody.AddForce(accelMovement * Time.fixedDeltaTime * Speed);
}
//iPhone Touch Control
if (UseTouch)
{
var mobileTouch_z : float = Input.touchCount;
var touchMovement : Vector3 = Vector3(0, mobileTouch_z * Sensitivity, 0);
rigidbody.AddForce(touchMovement * Time.fixedDeltaTime * Speed);
}
}