Realistic Effects Pack 4

by kripto289

Realistic Effects Pack 4 is by far one of the most popular particle packs on the store. It has a bunch of high quality effects that really go above and beyond. However, it has a very specific setup.

Install the Integration

Navigate to the "Asset Store Integrations" folder, and extract the .unitypackage for Realistic Effects Pack 4. This will install the prefabs and any other required assets.

If you have Realistic Effects Pack 4 already instealled, the Projectiles should work right away. There is also a demo scene ready to go for you to test and see them in action.

Unique Considerations

The projectiles in this package add Rigidbody and Collider components to the particles at runtime. These are physics based and required for the particles to function properly.

This means that the collision with objects must be handled by the particle itself, rather than Projectile Power. We can work with this, however!

There is a OnCollisionHelper class, which you can add to the particle that will handle collisions. Assign the projectile, and whenever this object receives an OnCollisionEnter (or similar methods for Trigger, Exit, and Stay), it will call that event on the Projectile.

This also means you don't need a Collision Behavior on the Projectile.

Since these projectiles are fully set up, most of the customization will likely occur on the projectile prefab itself, rather than through Behaviors.

Collisions with various Layers

There are no layermasks in the Realistic Effects Pack 4 collision systems, so if we spawn multiple projecitles at the same position, they will collide with themselves. So, we need to make sure they always spawn in separate spot.

You could ensure the layers don't collide in the collision matrix settings. Or, you can use the options in the Spawn settings to push out the z position of the spawn position, as seen in this screenshot.

Limitations

Due to the way Realistic Effects Pack 4 has been constructed, not all particles are easily integrated. As an example, Effect16 uses the RFX4_RaycastCollision class to detect collisions using a raycast. Unfortunately this doesn't result in a Collision object, which is required to call the OnCollisionEnter method.

It is entirely possible to write additional helper scripts to get around this restriction, and the code below may help you do that if you'd like. However, in most cases it likely isn't worth the effort simply for one particle effect.

private void OnRaycastCollisionEnter(object sender, RFX4_PhysicsMotion.RFX4_CollisionInfo e)
{
     if ((projectile.collisionMask.value & 1 << e.HitGameObject.layer) == 0) return;
            
     // We know we hit something we'd like to pass into Projectile Power, however, we don't have a Collision
     // object -- and those have no constructors. We would have to create a new class of Projectile that has
     // custom methods to handle this case.
            
     // While that is possible, it is out of the scope for this integration example.
}

Additional Work Required

Due to the way Realistic Effects Pack 4 has been set up, getting the actions to behave as you'd like, both from your player character, and enemies / NPCs, will take additional effort on your part -- this is because your game is unique, and there are way too many potential ways to use, and set up, these Projectiles.

However, the integration has all of the effects set up in Projectile objects -- all that's left is the custom behaviors!

Here's some of the behaviors I think most devs who want to fully integrate this into their game, will have to do.

Damage

Unlike other integrations and demos, I didn't implement any damage system. Check the other demos for how pass damage to custom Actor classes. You'll need to do the same for these. Depending on the Realistic Effects Pack 4 effect you use, you may have to pass the damage to your Actor class in various ways.

Target Selection & Effect Positioning

Selecting the target, and then positioning the effect, is not straight forward. Each effect is different, and many of the "Area" effects don't spawn on top of the target. Further, some have directional impacts, so you'll need to decide where in relation to the target to spawn.

Some will even require understanding the height of the world.

All of this can be achieved, it's just some unique code and behaviors you'll have to write. Fortunately, it's very easy to create custom behaviors!

Last updated