Shell ejects a cosmetic casing from a Shootable Action, follows a kinematic arc, bounces, settles and returns to the object pool. Use it for firearm feedback; the fired round, inventory and impact modules own gameplay.
Build and connect the casing
- In Tools > Opsive > Ultimate Character Controller > Object Manager, enter a Name, choose Object Type > Shell, assign the casing model to GameObject, then select Build Object.
- Keep Shell, Rigidbody and a solid Capsule or Sphere Collider on the prefab root. Size the collider to the model and choose its Physics Material. Trigger colliders are excluded from trajectory casts.
- Leave Initialize On Enable disabled and keep Mass and Start Velocity Multiplier positive, normally
1. Shell makes its Rigidbody kinematic with frozen constraints; Trajectory Object drives movement and gravity. - Start with Collision Mode > Reflect. Set Impact Layers for the intended floors/walls and optionally assign Surface Impact for material-specific contact feedback.
- In the Shell settings, choose Lifespan, initially
10seconds, and Persistence, initially1. Their cleanup behavior is described below. - On the Shootable Action, enable Shell Effect in Fire Effects Module Group, adding it if absent. Assign the prefab to Shell.
- Assign Shell Location for every enabled perspective. Place it at the ejection port; its rotation determines the casing’s initial orientation.
- Tune Shell Velocity, Shell Torque and Shell Eject Delay against the active visible object’s axes. Keep the delay within the firing sequence and maintain valid perspective references until ejection.
Shell Location controls spawn pose. Velocity is transformed using the active visible object’s local axes, independently of Shell Location rotation. The casing receives the randomized ejection velocity without adding character movement velocity. Use a custom Fire Effect when character-velocity inheritance or a long, cancelable ejection sequence is required.
Tune the presentation
| Field | Default | Purpose |
|---|---|---|
| Shell Velocity | (3, 0, 0) to (4, 2, 0) |
Random local velocity: mainly positive X with some positive Y variation. Narrow the range for consistent ejection. |
| Shell Torque | (-50, -50, -50) to (50, 50, 50) |
Random initial spin; widen cautiously for more varied motion. |
| Shell Eject Delay | 0 |
Time between firing and ejection. Perspective/location references are resolved when it expires. |
| Lifespan | 10 |
Normal time before shrinking begins. |
| Persistence | 1 |
Probability control for keeping normal life after a low-speed impact. Lower values make early removal more likely. |
| Active Audio Clip Set | Empty | Flight audio, stopped by the first physical hit. |
| Surface Impact | None | Surface System feedback on valid contacts. |
The generated Audio Source uses Spatial Blend 1 and Max Distance 10, with sounds assigned separately. Use Surface Impact or On Collision Event for bounce-specific audio; reserve Active Audio for flight.
Launch velocity is divided by Mass × Start Velocity Multiplier. Tune the Shell Velocity range first and use positive scaling values. Gravity, damping, friction and Reflect Multiplier then shape the bounce. Hard impacts, above a velocity magnitude of 2 after the shared collision processing, add random torque. Softer impacts can trigger early removal according to Persistence.
With Persistence 1, soft impacts retain the normal lifespan. At normal expiry, shrinking starts and pool return follows half a second later. An early-removal decision sets the shrink start half a second after that hit, with return about one second after it. Repeated soft contacts can update that removal time; judge the result across several casings rather than one throw.
Verify ejection and reuse
Fire once while stationary: one casing should appear at the active Shell Location and move mainly along the visible object’s positive X axis with the default range. Fire repeatedly to check variation and clearance from the weapon/character. Switch perspectives and confirm each ejection location. Walk while firing to assess the presentation without inherited character velocity.
Test an included surface, excluded layer and trigger-only collider. Only included solid contacts should produce trajectory reflection and feedback. Compare Persistence 1 with a lower value over multiple soft impacts, then wait for shrinking/pool return. The next use should restore full scale and an enabled collider.
| Symptom | Check | Fix |
|---|---|---|
| No casing appears | Shell Effect, prefab and active Shell Location. | Enable the module and assign both prefab and perspective locations. |
| Casing appears without moving | Root Shell component and launch data. | Use the Shell prefab and valid positive trajectory scaling. |
| Wrong ejection direction | Visible-object axes and Shell Velocity. | Tune the local velocity range; rotating only Shell Location changes pose. |
| Contact has no sound | Surface Impact and clip assignments. | Configure surface feedback or a collision-event listener. |
| Casings disappear early | Persistence and repeated soft contacts. | Use Persistence 1 when soft hits should retain normal Lifespan. |
Treat shells as local presentation in multiplayer: random motion and resting positions can differ between peers. Keep damage, ammunition and authoritative results in their owning systems. Discard transient casings at load boundaries and let later shots create new feedback.
Developer reference
Shell derives from TrajectoryObject; custom callers use inherited Initialize(Vector3 velocity, Vector3 torque, GameObject owner). ShellEffect exposes Shell, ShellVelocity, ShellTorque, ShellEjectDelay and ShellLocation. It schedules ejection and uses ObjectPoolBase for spawning; Shell owns its pool return. The inherited On Collision Event receives a physical RaycastHit. Manage listeners with the pooled lifecycle and Events.