Hop! * Grunts *
Obstacle elements the simplest elements in the Traversal module. These allow characters to overcome obstacles by playing an animation and finalizing without the need of the player's input.
It all begins with a Game Object that has an Obstacle component. This component defines the bounds of the obstacle, the path a character will take to overcome it as well as a reference to an Obstacle Clip, which will define how it is traversed and using which animations.
(Vault Obstacle setup)
The Obstacle component has two distinct sections: The parameters and the Obstacle Path section.
The Clip field is one of the most important. An Obstacle Clip defines how the Obstacle will be traversed, including the animations, exit speed and multiple tweakable values.
The Delay In field defines how much time, in seconds will the character take to start moving along the path of the Obstacle.
The Traverse Mode defines how the character will move along the path and is tightly coupled with the Obstacle Path section, which is explained further below. There are multiple options:
- To First Point: The Character will move from its current position towards the first point defined in the path.
- To Last Point: The Character will move from its current position towards the last point defined in the path.
- To Closest Edge: The Character will move from its current position towards the first or the last point defined in the path (whichever is closer to the character).
- To Farthest Edge: The Character will move from its current position towards the first or last point defined in the path (whichever is further away from the character).
- From First To Last Point: The Character will move from its current position towards the first position in the path and will follow the points path forward until it reaches the end point.
- From Last To First Point: The Character will move from its current position towards the last position in the path and will follow the points path backwards until it reaches the first point.
- From Closest To Farthest: The Character will move following the path defined (either forward or backwards) depending on whether the first point is closer or farther that the last point.
- From Farthest To Closest: The Character will move following the path defined (either forward or backwards) depending on whether the first point is further away or closer that the last point.
The Obstacle Path is a collection of points that represent the path the character will follow to overcome the obstacle. How these points are traversed is defined by the Traverse Mode field (see section from above).
(Vault Obstacle Path: Blue represents the first point and Red the last one)
A Path Point has a set of values that represent how the character will interact with each of these points when traversing the Obstacle.
The Angle is a value that ranges from 0 to 360 and indicates the local rotation the character should look at when reaching this point.
The Commute To field allows an Obstacle to link the Character with another Obstacle or Climbable object after traversing the current one.
The Transition field allows to choose between transitioning to this point by either a fixed amount of time or by velocity.
By Time is useful for small obstacles and you prefer to keep the animation's length always the same, regardless of the distance between the Character and its destination. For example, vaulting uses a Time transition.
By Speed is usually used when the obstacle is larger and will take more than a few seconds to complete. For example, it's not the same traversing a Zip-Line that it's end points have a distance of 5 units than 100 units. Choosing by Speed allows the Character to traverse the obstacle at a constant speed.
The Easing field allows to slightly modify the pacing of the traversal. By default, traversing between points will use a constant Linear speed. However, some animations might look more polished using some kind of easing. For example, the built-in Zip Line Obstacle uses a Quad-In Easing option, which makes the Character feel like it grabs the line at starts gaining speed the further down it goes.
Th Rest Duration allows to stop the character's movement for a time before transitioning to the next point or ending the traversal. This is specially useful for obstacles like the Jump, where the character has a few milliseconds that represent the landing animation.
The Location field is another one that's very important. It represents the position of the point. It's calculated in Local Space respect of the Obstacle component's game object.
The Obstacle component defines where the Character moves to, the Obstacle Clip defines how they do it.
(Obstacle Clip for the built-in Vault Obstacle example)
Rotation Mode and Rotation Duration allows to define how the character will treat rotation when traversing the Obstacle. By default, all Obstacles will be set to Towards Destination. However, there might be some cases where you don't want characters to rotate at all.
The Ignore Collisions field allows the character to ignore any collisions with its Character Controller component.
The Animation field allows to define whether the Character will play an animation from an Animation Clip or use a Character State. Obstacles tend to use simple Animation Clips, although some more advanced ones, such as the Wall-Run or the Zip-Line, use Character States to adapt to the duration of the obstacle traversed.
The Handles Offset Forward and Upward define the point, in self local space, from which this particular obstacle the handle will be.
By default, the handles are located at the root of the object (bottom of a character). However, some obstacles might require the handles to be located around the center of the body or even up around the head. This is where you can define an offset for the handles.
The Obstacle Clip also allows to slightly tweak the movement applied using 3 animation curves: Curve Offset X, Y and Z. These curves are applied in local space, relative to the character (being the Z axis forward).
To make the whole traversal feel as smooth as possible, each Obstacle Clip has a cross-fade value that determines how long, in seconds, will it take to go from the current Character's animation to the one used as part of the Climbable Clip.
These fields are Transition In and Transition Out. We recommend using values between 0.1 and 0.5 seconds. Lower values will break the transition and higher ones might look too smooth and make the Character appear like it's floating.
Because not all obstacles allow to keep the momentum of the action, the last field is Exit Speed. This allows to define how the character will behave after exiting the current Obstacle phase.