Changing my movement script to work on mobile too C#
Hello, I made a 2D Platform game check here :) and now I'm trying to make for mobile.
My move work on keyboard, but not with mobile touch, and I'm following this video, but my movement is a little diferent from there, my sprite changes direction. So, I have this:
public float moveSpeed;
private float activeMoveVelocity;
public bool onGround;
private bool onPlatform;
public float onPlatformVelocityAdjustment;
if (takeCountDamage <= 0 && canMove)
{
if (onPlatform)
{
activeMoveVelocity = moveSpeed * onPlatformVelocityAdjustment;
} else {
//activeMoveVelocity = moveSpeed;
}
if (Input.GetAxisRaw ("Horizontal") > 0f)
{
playerRigidbody.velocity = new Vector3 (activeMoveVelocity, playerRigidbody.velocity.y, 0f);
transform.localScale = new Vector3 (1f, 1f, 1f);
} else if (Input.GetAxisRaw ("Horizontal") < 0f)
{
playerRigidbody.velocity = new Vector3 (-activeMoveVelocity, playerRigidbody.velocity.y, 0f);
transform.localScale = new Vector3 (-1f, 1f, 1f);
} else {
playerRigidbody.velocity = new Vector3 (0f, playerRigidbody.velocity.y, 0f);
}
if (Input.GetButtonDown ("Jump") && onGround)
{
Jump ();
JumpSound.Play();
}
}
public void Jump()
{
playerRigidbody.velocity = new Vector3 (playerRigidbody.velocity.x, jumpSpeed, 0f);
}
The problem is that I dont know what to change on my script to make my Dpad to work. I already put the left button, the right button and the button for jump.
Sorry for the trouble. (and I'm new at programming and speaking in English)
Comment