/// <summary> /// Moves the character to the specified position. Will create a MoveTowardsLocation if one is not already created. /// </summary> /// <param name="position">The position to move towards.</param> public void MoveTowardsLocation(Vector3 position) { InitializeMoveTowardsLocation(); m_IndependentMoveTowardsLocation.transform.position = position; m_IndependentMoveTowardsLocation.Angle = 360; // Any arriving location is valid. // The position can be updated while the ability is active. if (IsActive) { if (m_PathfindingMovement != null && m_PathfindingMovement.IsActive) { m_PathfindingMovement.SetDestination(position); } } else { StartAbility(); } }
/// <summary> /// The ability has started. /// </summary> protected override void AbilityStarted() { if (m_OnArriveAbility != null) { m_AllowEquippedSlotsMask = m_OnArriveAbility.AllowEquippedSlotsMask; m_OnArriveAbility.AbilityMessageCanStart = false; } base.AbilityStarted(); m_Arrived = false; if (m_DisableGameplayInput) { EventHandler.ExecuteEvent(m_GameObject, "OnEnableGameplayInput", false); } // The MoveTowardsLocation may already be set by the starting ability within StartMoving. if (m_MoveTowardsLocation == null) { m_MoveTowardsLocation = m_IndependentStartLocation; } // The movement speed will depend on the current speed the character is moving. m_MovementMultiplier = m_MoveTowardsLocation.MovementMultiplier; if (m_SpeedChangeAbilities != null) { for (int i = 0; i < m_SpeedChangeAbilities.Length; ++i) { if (m_SpeedChangeAbilities[i].IsActive) { m_MovementMultiplier = m_SpeedChangeAbilities[i].SpeedChangeMultiplier; break; } } } // Use the pathfinding ability if the destination is a valid pathfinding destination. if (m_PathfindingMovement != null && m_PathfindingMovement.Index < Index) { m_PathfindingMovement.SetDestination(m_MoveTowardsLocation.TargetPosition); } // Force independent look so the ability will have complete control over the rotation. EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", true); }
/// <summary> /// The ability has started. /// </summary> protected override void AbilityStarted() { // The ability can be null on the network. if (m_OnArriveAbility != null) { m_AllowEquippedSlotsMask = m_OnArriveAbility.AllowEquippedSlotsMask; } base.AbilityStarted(); m_Arrived = false; // Use the pathfinding ability if the destination is a valid pathfinding destination. if (m_PathfindingMovement != null && m_PathfindingMovement.Index < Index) { m_PathfindingMovement.SetDestination(m_StartLocation.GetTargetPosition()); } // Force independent look so the ability will have complete control over the rotation. EventHandler.ExecuteEvent(m_GameObject, "OnCharacterForceIndependentLook", true); }