Skip to main content

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-side canHit 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.
For keyboard attacks, configure the action key to send the same payload:
This same input shape can be reused for future map or event interactions, for example 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

Use repeat 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.
Use pattern for common shapes:

Impact Hooks

Use projectile hooks to apply gameplay effects when the server confirms an impact:
You can also filter hits per projectile:
If the 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.
Common props:
  • id, type, ownerId
  • x, y, origin, direction, angle
  • speed, range, ttl, distance, elapsed, progress
  • impactProgress from 0 to 1 while the client keeps an impacted projectile visible for its impact animation
  • index, count for repeated or patterned projectiles
  • params for visual customization
  • impact when the server confirms a collision. While impact is present, x, y, and distance are pinned to the authoritative impact point. Before the server confirmation arrives, the client may also pin x, y, and distance to a locally predicted impact point; impact remains undefined until the server confirms the collision.
Do not apply damage in the component. Components are visual only; gameplay effects belong in server projectile hooks.