using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody2D rb;
public float speed;
public Animator animator;
bool walk = false;
void Start()
{
walk = false;
}
// Update is called once per frame
void Update()
{
if(Input.touchCount == 1)
{
Touch touch = Input.GetTouch(0);
if(touch.position.x > (Screen.width / 2))
{
rb.velocity = new Vector2(speed, 0);
walk = true;
}else if(touch.position.x < (Screen.width / 2))
{
rb.velocity = new Vector2(-speed, 0);
walk = true;
}
if(walk == true)
{
animator.SetBool("Walk", true);
Debug.Log("moving");
}
if(walk == false)
{
animator.SetBool("Walk", false);
Debug.Log("not movingggg");
}
}
}
}
,