The Trajectory Object is the base component for any object that is projected from the character.This can include a wide range of objects including rockets, arrows, grenades, or shells. If the Trajectory component is added directly to the character then it can also show a trajectory curve of the direction that the object will follow.

Visible Trajectory Curve Setup

The Trajectory Object component can optionally display a curve indicating where the object is going to move towards when launched. This is a deterministic curve so the path will be accurate for where the object lands. This curve can also be used within VR to show the location that the first person player is going to teleport to.

  1. Select the GameObject that you want the curve to affect. For our example we selected the Nolan/Items/PrimaryFragGrenade GameObject since this curve should be displayed by the ThrowableItem.
  2. Add the following components:
    • Trajectory Object
    • Line Renderer
    • Capsule Collider. This component is optional and can be nothing, a Capsule Collider, or Sphere Collider.This component will tell the Trajectory Object what type of collisions to use (if no collider is added a standard raycast is used). The Capsule Collider was chosen for this example because the frag grenade uses a Capsule Collider.
  3. The Trajectory Object values should match the values of the Trajectory Object that is being used. For this example all of the default Trajectory Object values can be left alone.
  4. The following Line Renderer values should be changed:
    • Cast Shadows: Off
    • Receive Shadows: Disabled
    • Materials: your Line Renderer material
    • Positions: 0
    • Width: 0.15
  5. The Capsule Collider values should match the Capsule Collider values on the object being used (the frag grenade):
  6. The final step is to enable the trajectory upon aim with the frag grenade.This can be found under the Trajectory foldout of the ThrowableItem component:

Inspected Fields

Initialize On Enable

Should the component initialize when enabled?

Mass

The mass of the object. The mass affects the velocity, the larger the mass the less the velocity.

Start Velocity Multiplier

A multiplier to apply to the starting velocity.This is useful for simulation when the trajectory curve should account for any velocity that is added to the character when the object is being thrown.

Gravity Magnitude

The amount of gravity to apply to the object. The gravity direction is determined by the character’s up direction.

Speed

The movement speed of the object. This value is multiplied by the velocity to give the final new position.A larger speed value is most useful if the trajectory curve is visible to reduce the number of total positions.

Rotation Speed

The rotation speed of the object. This value is slerped between the original rotation and the target rotation.

Damping

The damping value to apply to the movement.The higher the damping the quicker the object will stop moving.

Rotation Damping

The damping value to apply to the rotation. The higher the damping the quicker the object will stop rotating.

Rotate In Move Direction

Should the object rotate in the direction that the object is moving? This is useful for a bow and arrow where the arrow should face in the movement direction.

Settle Threshold

When the velocity and torque have a square magnitude have a square magnitude value less than the specified value then the object will be considered settled.Settled objects do not update anymore and will not move/rotate.Set to 0 if the object should never settle.

Sideways Settle Threshold

Specifies if the collider should settle on its side or upright.The higher the value the more likely the collider will settle on its side. This is only used for CapsuleColliders and BoxColliders. This is useful for bullet shells when you want them to land upright.

Start Sideways Velocity Magnitude

Starts to rotate to the settle rotation when the velocity magnitude is less than the specified values.

Impact Layers

The layers that the object can collide with.

Surface Impact

The identifier that is used when the object collides with another object. If the identifier is null it can be overridden by the object initializing the trajectory object.

Force Multiplier

When a force is applied the multiplier will modify the magnitude of the force.

Bounce Mode

Specifies how the object should bounce after hitting another collider.

  • None: Do not bounce
  • Reflect: Reflect according to the velocity
  • Random Reflect: Reflect in a random direction.This mode will make the object nondeterministic but for visual only objects such as shells this is preferred.
Bounce Multiplier

Specifies the multiplier to apply to the bounce velocity (if the object can bounce).

Max Collision Count

The maximum number of objects that the projectile can collide with at a time.

Max Position Count

The maximum number of positions any single curve amplitude can contain.This is only used when the curve is being displayed.