CircleCollider2D
Namespace:
namespace Lenga\Engine\Core;
class CircleCollider2D
Methods
getContacts
public function getContacts(bool $includeTriggers = true, ?int $layerMask = null)
Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\CircleCollider2D;
class BallCollider extends Behaviour
{
public function start(): void
{
$collider = $this->getComponent(CircleCollider2D::class);
$collider->radius = 0.5;
}
public function update(): void
{
$collider = $this->getComponent(CircleCollider2D::class);
$contacts = $collider->getContacts();
if (count($contacts) > 0) {
Debug::log('Ball is in contact with ' . count($contacts) . ' object(s)');
}
}
}