public virtual void OnUpdate() { var move = new Vector3(Input.GetAxisRaw("Horizontal"), 0, 0); Rigidbody2D rb = player.GetComponent <Rigidbody2D>(); rb.velocity = new Vector2(move.x * player.moveSpeed, rb.velocity.y); if (player.GetComponent <SpriteRenderer>().sprite == player.walking) { player.GetComponent <Animator>().speed = player.isGrounded ? Mathf.Abs(Input.GetAxisRaw("Horizontal")) : 0; } }
// Start is called before the first frame update void Start() { player = FindObjectOfType <PlayerController2D>(); camera = FindObjectOfType <CameraController>(); rend = player.GetComponent <Renderer>(); healthManager = FindObjectOfType <HealthManager>(); }