Obstacles

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)

Obstacle Component

The Obstacle component has two distinct sections: The parameters and the Obstacle Path section.

Parameters

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.

Obstacle Clips are meant to be reused in multiple places.

For example, your game might have thousands of Vaultable obstacles in a single level, at different positions, rotations and sizes. However, you can reuse the same Obstacle Clip for all of them.

That's why there's a distinction between Obstacles, which define the available paths to overcome them, and Obstacle Clips, which define how it will be traversed.

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.

Obstacle Path

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).

The Obstacle Path typically has 1 or at most 2 points. However, the Traversal module gives you the option to create as many path points as you want.

(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.

Obstacle Clip

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.

IMPORTANT NOTE ON ANIMATIONS: It is very important to understand that Animation Clips played while traversing an obstacle will stretch to fit the length of the traversing.

This is very useful because vaulting over a small obstacle that takes, for example, 0.2 seconds, or vaulting over a bigger one that takes 0.8 seconds, will look exactly the same, as the animation will be stretched to last 0.2 seconds in the first case and 0.8 seconds on the latter.

Animations adapt to the Obstacle's duration and not vice-versa.

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).

Curves are particularly useful when a character needs to trace a curved trajectory instead of following a straight path. F

or example, When a character performs an horizontal Wall-Run, it slightly moves upward to then slowly lose momentum and go down. This effect can be achieved modifying the Curve Offset Y so it starts at 0, builds up to a certain value around half way and then goes down back to 0.

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.

Last updated

Was this helpful?