Emitters
On this page
Projectiles
The projectile is the emitter output type most commonly used in a project and it is split into two parts; the projectile state and a projectile actor. The projectile state is a lightweight struct which stores the information about the projectile (such as position and velocity) which can then be easily simulated forward every frame. Keeping this light also means that it is very easy and cheap to roll back to a previous state if required.
Then there is the projectile actor which is a physical representation of what is happening in the projectile state. It binds to the relevant events within the state and then updates in the render tick rather than in the network tick to ensure the visuals of the projectile are smooth. This is not spawned on the dedicated server as there is no need for visuals.
Each projectile is given a unique ID so that they can be identified and matched between server and client. However, they are not replicated so they expect to be set up correctly initially so they can be simulated the same on all clients. The client sends the spawn intention to the server via Server_SendEmitterSpawnCueOverride which the server checks for before creating a projectile and then validates against its own data with ValidateClientEmitterData to ensure the data has not been tampered. If valid, the server will restore state back to the frame that the client created the projectile locally and simulate forwards until the projectile hits an object that stops the simulation or it catches up to the current server timeline. This hit is then applied to the simulation which is then eventually replicated back out to clients to verify that the prediction was correct.