I implemented the movement of the player by touching a left (void public WalkLeft) or right (void public WalkRight) arrow placed on my scene in Unity 2D. But running the game, I discovered that when I tap on the left or right button the player moves jerkily/flick and not smoothly like when I use my pc keyboard.
Here is my code:
public void WalkRight (){
gameObject.transform.rotation =Quaternion.Euler(0,180,0);
gameObject.transform.position +=Vector3.right *Time.deltaTime *5;if(jumping ==false){
anim.Play(“personaggioCorsa”);}
moving =true;
left_dir =false;
moveVector =newVector3(1f,0.35f,0);
}
public void WalkLeft (){
gameObject.transform.rotation =Quaternion.Euler(0,0,0);
gameObject.transform.position +=Vector3.left *Time.deltaTime *5;if(jumping ==false){
anim.Play(“personaggioCorsa”);}
moving =true;
left_dir =true;
moveVector =newVector3(-1f,0.35f,0);
}
public void Jump (){
rb.velocity =newVector3(0, jumpspeed,0);
jumps = jumps +1;Debug.Log(“Psycho sta Saltando”);
/*
Vector2 move = new Vector2 (0, 20);
rb.AddForce (move * speed);
anim.Play (“personaggioSalto”);
jumping = true;
if(!doubleJumped)
{
//rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x, jumpHeight);
//Jump();
rb.AddForce(Vector3.up* jumpHeight);
//rb.AddForce(new Vector2(0, jumpHeight), ForceMode2D.Impulse);
doubleJumped = true;
}
*/
}