I have this script (courtesy of Alucardj) and it is a script for running and playing the footstep sounds. Now since I am trying to apply this script (which is for PC) into my Android game, how will I be able to convert the "hold the shift button to run" mechanic, into "hold the right touch pad to run"?
Here is the portion of the script:
function SetSpeed()
{
var speed = walkSpeed;
if ( chCtrl.isGrounded && Input.GetKey("left shift") || Input.GetKey("right shift") )
{
speed = runSpeed;
}
chMotor.movement.maxForwardSpeed = speed;
}
function PlayFootsteps()
{
if ( Input.GetAxis( "Horizontal" ) || Input.GetAxis( "Vertical" ) )
{
if ( Input.GetKey( "left shift" ) || Input.GetKey( "right shift" ) )
{
// Running
isWalking = false;
isRunning = true;
}
else
{
// Walking
isWalking = true;
isRunning = false;
}
}
else
{
// Stopped
isWalking = false;
isRunning = false;
}
↧