Move Towards Location
The Move Towards Location is an extremely useful component which determines where the character should move towards when starting an ability. It allows for both a positional and rotational threshold so the character doesn’t have to land on the precise point in order for the ability to start. The Move Towards ability will do the actual movement of the character to the closest Move Towards Location.
Setup
- Select the object that is being interacted with (the button, ladder, door, etc) and add the Move Towards Location component. In the case of the Interact ability the object selected should be the same object that the Animated Interactable component is attached to.
- Adjust the Offset and Rotation Offset fields so the gizmo in the editor will be oriented in the position and direction that the character should start the ability in. As an example for the button press interact ability the gizmo should be positioned where the character should stop and start reaching out their hand to press the button.
- If the position or rotation is more variable for when the ability starts then the Size and Angle fields should be adjusted. Adjusting the Size will show an orange line indicating the location that is considered to be valid. A lighter green color will fill in the circle indicating the variance allowed for the angle.
Ability Setup
The Ability class has a virtual method which allows the ability to return an array of Move Towards Location objects:
/// <summary> /// Returns the possible MoveTowardsLocations that the character can move towards. /// </summary> /// <returns>The possible MoveTowardsLocations that the character can move towards.</returns> MoveTowardsLocation[] GetMoveTowardsLocations()
By returning the possible start locations it indicates to the controller that the ability requires the character to be in a specific location before the ability can start. As an example the Interact ability will return the MoveTowardsLocation on the GameObject that can be interacted with:
public override MoveTowardsLocation[] GetMoveTowardsLocations() { return m_Interactable.gameObject.GetCachedComponents<MoveTowardsLocation>(); }
Inspected Fields
Offset
The offset relative to the transform that the character should move towards.
Rotation Offset
The rotation offset relative to the transform that the character should rotate towards.
Size
The size of the area that the character can start the ability at. A zero value indicates that the character must land on the exact offset.
Distance
The ability can start when the distance between the start location and character is less then the specified value.
Angle
The ability can start when the angle threshold between the start location and character is less than the specified value.
Require Grounded
Is the character required to be on the ground?
Precision Start
Should the ability wait to start until all transitions are complete?