R3d.World:testOverlap

From GiderosMobile
Revision as of 21:40, 16 December 2025 by MoKaLux (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2019.10
Class: R3d.World

Description

World Query Collider. Checks if the colliders of two bodies overlap.

(bool) = r3d.World:testOverlap(bodyA,bodyB)

A world query collider is a collider used to perform world queries on it. World queries are manual queries performed on the physics world.

You can use this if you just want to know if bodies are colliding but your are not interested in the contact information.

Parameters

bodyA: (body) the first body to test collisions with
bodyB: (body) the second body to test collisions with

Return values

Returns (boolean) either true or false

Examples

local c = 1
function collisionsEventListener()
	if world:testOverlap(shipvp.body, ground01body) then
		print("collision", c)
		c += 1
	end
end
world:setEventListener(collisionsEventListener)

Or

stage:addEventListener(Event.ENTER_FRAME, function(e)
	world:step(e.deltaTime)
	local bool = world:testOverlap(player1.body, obj01.body)
	print(bool)
end