Skip to content

@modoki/engine / index / shapeCast2D

Function: shapeCast2D()

shapeCast2D(world, ox, oy, dx, dy, radius, opts?): { distance: number; entityId: number; nx: number; ny: number; x: number; y: number; } | null

Sweep a circle of radius (world units) from (ox,oy) along (dx,dy) and return the first collider it would hit — the "would this fit if I move it here" query. Like raycast2D but with thickness. maxDistance in world units. NOTE: x,y is the swept circle's CENTER at impact (not the surface contact point, as raycast2D returns) — pair it with radius + nx,ny if you need the contact.

Parameters

world

World

ox

number

oy

number

dx

number

dy

number

radius

number

opts?

maxDistance?

number

Returns

Type Literal

{ distance: number; entityId: number; nx: number; ny: number; x: number; y: number; }

Physics

distance

distance: number

entityId

entityId: number

nx

nx: number

ny

ny: number

x

x: number

y

y: number


null

Built with Modoki.