public override void Action() { animator.SetBool(walkingAnimationId, animator != null && walkingAnimationId > 0); if (target != null && walkingBeheivor != null) { Vector3 diff = target.transform.position - transform.position; diff.Normalize(); float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg; transform.rotation = Quaternion.Euler(0f, 0f, rot_z - 90); if (Mathf.Abs(this.transform.position.x - target.gameObject.transform.position.x) < minimumDistance) { directionHorizontal = 0; } else { directionHorizontal = target.transform.position.x > transform.position.x ? 1f : -1f; } if (Mathf.Abs(this.transform.position.y - target.gameObject.transform.position.y) < minimumDistance) { directionVertical = 0; } else { directionVertical = target.transform.position.y > transform.position.y ? 1f : -1f; } walkingBeheivor.MovementSpeedMultiplier = speedMultiplier; walkingBeheivor.SetHorizontalMove(directionHorizontal); walkingBeheivor.SetVerticalMove(directionVertical); } }
protected virtual void ChangeDirection(float x, float y) { if (!inOutLimits) { walking.SetHorizontalMove(x); walking.SetVerticalMove(y); } }
public void FallBack() { directionHorizontal = target.transform.position.x < transform.position.x ? 1f : -1f; directionVertical = target.transform.position.y < transform.position.y ? 1f : -1f; walkingBeheivor.MovementSpeedMultiplier = speedMultiplier; walkingBeheivor.SetHorizontalMove(directionHorizontal); walkingBeheivor.SetVerticalMove(directionVertical); Debug.Log("Fallback when attacked....."); }