Projectiles
Use projectiles for arrows, spells, bullets, beams, and other temporary moving effects that need server-side impact validation without synchronizing their position every frame. The server is authoritative. It emits compact projectile spawn, impact, and destroy batches. The client predicts the visual movement locally, including a single local raycast at spawn time to avoid drawing projectiles past obvious client-side hitboxes while it waits for the server impact, and renders each projectile with a registered CanvasEngine component. When a projectile uses a custom server-sidecanHit filter, the client keeps
predicting movement but skips local impact raycast clamping by default because
arbitrary server gameplay rules cannot be represented safely on the client. If
the filter still matches client-visible physics, opt back in with
collision.predictImpact: true.
Server Usage
Emit a projectile from a player:spreadDegrees applies a random direction offset of +/- spreadDegrees / 2.
You can use accuracy instead when you prefer a normalized precision value
from 0 to 1; 1 is perfectly accurate, 0 can deviate up to 30 degrees.
payload stays server-side and is useful for damage, states, knockback, or any
other gameplay data. params is sent to clients and should contain only visual
data used by the projectile component.
You can also emit from the map:
Shoot Toward The Pointer
Projectiles can also use a direction vector. For pointer-based attacks, send the target position through the normal action input flow, then validate and resolve the shot on the server.map:click with a world position or event:click with an event id. The
client sends intent and context; the server still owns validation, collisions,
damage, and impacts.
Repeats And Patterns
Userepeat for a compact burst. The server broadcasts one spawn batch with
per-projectile delays, so clients can render the whole burst without receiving a
position update every frame.
pattern for common shapes:
Impact Hooks
Use projectile hooks to apply gameplay effects when the server confirms an impact:canHit filter only narrows server gameplay targets and the normal map
physics hitboxes are still safe for visual prediction, enable local clamping:
Client Registration
Register a CanvasEngine component for each projectile type:Projectile Component
Projectile components receive predicted movement props from the client runtime.id,type,ownerIdx,y,origin,direction,anglespeed,range,ttl,distance,elapsed,progressimpactProgressfrom0to1while the client keeps an impacted projectile visible for its impact animationindex,countfor repeated or patterned projectilesparamsfor visual customizationimpactwhen the server confirms a collision. Whileimpactis present,x,y, anddistanceare pinned to the authoritative impact point. Before the server confirmation arrives, the client may also pinx,y, anddistanceto a locally predicted impact point;impactremains undefined until the server confirms the collision.