private void MoveTowardLocation(Vector3 location) { _animationType = AnimationMode.Loop; if (Mathf.Abs(location.x - transform.position.x) < AttackDistance) { LogMessage("Close enough, not moving."); return; } LogMessage("Moving towards " + location); if (location.x < transform.position.x) { _currentAnimation = MoveLeft; _isFacingLeft = true; _movement.MoveHorizontally(false); return; } else if (location.x > transform.position.x) { _currentAnimation = MoveRight; _isFacingLeft = false; _movement.MoveHorizontally(true); return; } }
public void MoveTowardLocation(Vector3 location) { if (IsCloseToTarget(location)) { if (DebugMode) { Debug.Log("Close enough to " + location + ", don't need to move."); } return; } if (location.x < transform.position.x) { IsFacingLeft = true; _movement.MoveHorizontally(false); } else if (location.x > transform.position.x) { IsFacingLeft = false; _movement.MoveHorizontally(true); } if (DebugMode) { Debug.Log("(" + Time.time + ") Moving " + (IsFacingLeft ? "Left" : "Right") + " from " + transform.position); } }
public void MoveInDirection() { if (_facingLeft) { _animation = moveLeft; _movement.MoveHorizontally(false); } else { _animation = moveRight; _movement.MoveHorizontally(true); } }
public void ChooseAction() { if (_sense.PlayerLocation.position.x < transform.position.x) { _facingLeft = true; _movement.MoveHorizontally(false); } else { _facingLeft = false; _movement.MoveHorizontally(true); } FireProjectile(); DecideToJump(); }
private void MoveTowardLocation(Vector3 location) { _animationType = AnimationMode.Loop; if (Mathf.Abs(location.x - transform.position.x) < MinimumHomingDistance) { if (DebugMode) { Debug.Log("Close enough, not moving."); } return; } if (DebugMode) { Debug.Log("Moving towards " + location); } if (location.x < transform.position.x) { if (DebugMode) { Debug.Log("Moving left..."); } _currentAnimation = WalkLeft; _isFacingLeft = true; _movement.MoveHorizontally(false); return; } else if (location.x > transform.position.x) { if (DebugMode) { Debug.Log("Moving right..."); } _currentAnimation = WalkRight; _isFacingLeft = false; _movement.MoveHorizontally(true); return; } }
private void CheckHorizontal() { if (!Input.GetButton("Horizontal")) { isMovingHorizontally = false; _movement.ClearHorizontalMovement(); return; } isFacingRight = Input.GetAxis("Horizontal") > 0; if (isCrouching) { return; } DebugMessage("The player is moving!"); isMovingHorizontally = true; _movement.MoveHorizontally(isFacingRight); }
protected void DetectHorizontalMovement() { if (!canMove) { return; } if (_control.GetAxis(HorizontalAxis) > 0) { _isMovingHorizontally = true; isFacingRight = true; } if (_control.GetAxis(HorizontalAxis) < 0) { _isMovingHorizontally = true; isFacingRight = false; } if (_isMovingHorizontally) { _movement.MoveHorizontally(isFacingRight); } }