Magic Projectile
A Magic Projectile gives a Magic Action a moving fireball or similar pooled effect whose contact enters the spell’s Impact Module Group. Magic Projectile is an Object Manager recipe using the standard Projectile component and a Particle System.
Build a one-hit fireball
- In Tools > Opsive > Ultimate Character Controller > Object Manager, enter a Name and select Object Type > Magic Projectile. This recipe creates its own Particle System rather than accepting a model through GameObject.
- Leave Magic Particle Collisions disabled for one root-projectile hit. Select Build Object and save the prefab.
- Keep Rigidbody, Particle System and Projectile on the root. Add a solid Sphere or Capsule Collider sized to the visible fireball when it needs collision volume; without a supported collider, trajectory movement uses a raycast. Triggers are excluded.
- Configure the particle material, emission, lifetime and renderer. Projectile starts its root Particle System at launch.
- Leave Initialize On Enable disabled, keep Mass and Start Velocity Multiplier positive, explicitly select Collision Mode > Collide and enable Destroy On Collision. Use Destruction Delay
0for immediate destruction and a positive Lifespan, initially10seconds, for a missed shot. - Configure Default Impact Damage Data. Its layer mask and Surface Impact normally become the Projectile’s active fields; enable Use Object Impact Layer And Surface to retain the object’s own values instead.
- Disable Internal Impact when the Magic Action’s Impact group owns damage. For a particle tail after contact, enable Wait For Particle Stop: movement/emission stop and pool return waits for the root Particle System’s main Duration, replacing Destruction Delay. Coordinate child effects and trails separately.
See Trajectory Object for gravity, damping, collision and settling settings, and Projectile for shared destruction and sticking behavior.
Connect the Magic Action
- Configure the Magic Action with an enabled Trigger and Simple Caster. Add Spawn Projectile to Cast Effects Module Group.
- Assign the prefab to Projectile Prefab. It must contain Projectile on its root.
- Align the Caster’s Cast Origin for both enabled perspectives, then adjust Position Offset and Rotation Offset from their
(0, 0, 0)defaults. Position offset follows the character’s rotation around the cast position; rotation offset adjusts the cast-direction orientation. - Set Speed, initially
1. The module launches along the current cast direction at that magnitude, before trajectory scaling. - Leave Parent To Origin disabled for independent world-space flight; enable it only when the moving effect should remain under the origin Transform.
- For one projectile per use, choose Delay
0, Initial Delay-1and a non-continuous Caster. Allow Multi Target starts enabled; disable it unless one projectile per selected target is intended. - Add Generic Magic Impact Module to Impact Module Group, then configure Conditions and the pass/fail Impact Action Groups.
The Cast Effect completes after spawning. Stopping or interrupting the cast leaves the projectile’s own collision/lifetime policy in charge. Add explicit tracking and recall in a custom module if stopping a spell must remove its launched objects.
Choose one collision owner
| Design | Configure | Result and cleanup |
|---|---|---|
| One physical fireball | Root Collide, collision destruction enabled, Internal Impact disabled; no Magic Particle. | Magic Impact group runs on contact; collision or Lifespan returns the root. |
| Individual particle hits | Add Magic Particle, configure particle collisions, and exclude the root trajectory from those targets. | Particle contacts invoke Magic impacts; retain a tested root lifetime/pool return. |
| Prefab-local result | Enable Internal Impact and leave the Magic Impact group empty. | The Projectile’s local Impact Action Group owns the result. |
| Pass-through root | Ignore, collision destruction disabled, deliberate impact filtering. | Supply project-owned lifetime and cleanup. |
For particle hits, enable Particle System Collision and Send Collision Messages, set Collides With, and follow Magic Particle. The Object Manager toggle adds the component; configure the Collision module yourself. Keep root and particle collision masks separate so the same encounter produces the intended number of results.
A root collision reaches the Magic Action first, then the prefab’s local group when Internal Impact is enabled. Configure both only when two results are intentional. Projectile’s first contact cancels its launch Lifespan, so bouncing or pass-through designs need their own post-contact cleanup.
Verify the cast
Cast once and confirm the fireball leaves the active perspective’s origin, travels in the intended direction and invokes the chosen impact group once on an included solid target. Test an excluded layer and trigger-only target, then miss all targets and confirm pool return after Lifespan. Switch perspectives and recast while moving to check offsets and parenting. Reuse the prefab and verify collider, particles, lifetime, ignored character contacts and ownership reset.
| Symptom | Check | Fix |
|---|---|---|
| Projectile is missing or stationary | Prefab root and module assignment. | Assign the root-Projectile prefab to Spawn Projectile. |
| Damage/effects occur twice | Root, particle and Internal Impact paths. | Choose one collision owner and one primary gameplay group. |
| Fireball detects only its center line | Root collider. | Add a solid Sphere or Capsule matching the visible volume. |
| Impact hits unexpected layers | Default impact data versus object override. | Configure the active mask and surface ownership deliberately. |
| Fireball moves with the wand | Parent To Origin. | Disable it for independent flight. |
Register the prefab through the installed multiplayer integration and verify one authoritative impact/destruction result on server, owner and observer. Finish or discard transient flights around load boundaries.
Developer reference
Opsive.UltimateCharacterController.Items.Actions.Modules.Magic.CastEffects.SpawnProjectile implements IProjectileOwner. Its impact callback forwards the cast ID and ImpactCallbackContext to MagicAction.PerformImpact; destruction restores ignored character/projectile collider pairs. MagicParticle.Initialize(MagicAction, uint castID) configures the separate particle route. The Magic Action publishes OnMagicItemCast(CharacterItem); impact events such as OnObjectImpact depend on configured Impact Actions. Register and unregister listeners with the pooled lifecycle; see Events.