private void Awake()
 {
     _playerAnimation = GetComponent <PlayerAnimation>();
     _rb2D            = GetComponent <Rigidbody2D>();
     // Set the target position to the spawn position.
     _targetPosition = transform.position;
     // Update the colliders.
     _rb2D.MovePosition(_targetPosition);
 }
Example #2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
        private void Move()
        {
            float speed = (state == Status.Running) ? runningSpeed : moveSpeed;

            rb.velocity = new Vector2(speedDir * speed, rb.velocity.y);

            if (canJump && wantsToJump)
            {
                PlayerJump.Jump();
            }

            PlayerAnimation.ChangeSprite();
        }