🕊️Behaviors

v1.0

Scripting and code examples are included as a page under each Behavior or other section. Expand them out to see specific details for each class.

Behaviors are what drive the behavior (GET IT???) of the particles. Each particle is made up of a number of mostly optional behaviors which change how they are spawned, how they move, their visual or audio effects, and how the ultimately are destroyed.

Copying an existing Particle and changing one behavior will create a new version with distinct properties.

To create a Projectile Power Behavior, right click in the Hierarchy, and select Create/Projectile System/[Behavior Type]/[Behavior You'd Like]

If you create new classes which inherit from existing behaviors, you can set up the default name & path to create the objects by copying and modifying the CreateAssetMenu code on the existing behaviors.

Behavior types

There are two main types of behaviors: Spawn Behavior, and Projectile Behavior. There is also the Spawn Behavior Modification which is related to the Spawn Behavior.

Spawn Behavior

This is the class that determines how the Projectiles are spawned. It is extensible, so you can create new classes which inherit from the one in the package to add new custom spawning logic. The included SpawnBehavior class has a plethora of options to create many many ways of spawning projectiles, from a single shot to an infinite repetition of shots in a pattern.

Spawn Behavior Modification

These classes can be attached to projectiles, and will be run against each Projectile as it is spawned, before any other behaviors call their OnLaunch() methods.

In the demo scene, the arrows and other physics-based projectiles use a SpawnBehaviorModification (PhysicsVelocity and PhysicsVelocityModified) to set the desired velocity of the projectiles. Due to this, there is no Movement Behavior on these projectiles -- physics will handle that!

You can create new Spawn Behavior Modification classes if there are unique things you'd like to accomplish.

Projectile Behavior

Each Projectile has a number of behaviors available to be populated. These are all optional, though some are more likely to be populated than others, such as the DestroyBehavior...otherwise the projectile will never go away.

  • Movement Behavior handles how the projectile moves. Even if it moves with physics, a Movement Behavior class can add new logic to its motion.

  • Collision Behavior handles what to do when the projectile collides with other objects. Very handy behavior to have.

  • Destroy Behavior deals with destroying the projectile. Sometimes instant is good, other times you may wish to delay that. (Note: "Destroy" here really refers to putting the projectile back to the object pool. Same practical purpose though.)

  • Visual Effect Behavior can handle a particle system. While your projectile may have its own, this will allow you to add a particle to a projectile that otherwise does not have one. Check out the fire arrows in the demo -- same arrows, just with the fireball particle on it!

  • Projectile Audio Behavior can provide audio for your projectiles. The projectile prefbas themselves may have audio, and things that get hit may also have audio. There are many ways to do audio, so you may not use this, but perhaps you will for some use cases.

  • Trajectory Behavior can provide a visual trajectory while the projectile is in flight.

All of these behavior types inherit from the same ProjectileBehavior class, and subscribe to the Projectile for event-based methods and the Tick() and LateTick() methods tied to the Update() and LateUpdate() loops.

Last updated