Collision.getContacts returns only one contact point

I am trying to create an effect where a circle spawns from the feet of the player and expands around him. The circle should wrap to a wall if the player is near one (see picture), so in a way it’s not actually a circle but a sphere.


My goal was to use a sphere collider to achieve this, where the collider expands around the player and then draw a line on the perimeter of the sphere collider where it collides with wall or ground. However, when I use Collision.getContacts on the collision event, I only get one (1) collision point. I need to receive all the collision points (well, preferably only the edges of the collision). The size of the array given as a parameter to the function has no difference.

The image is created with a ray casting method, but it’s not a feasible solution as the circle is not very accurate without millions of rays which on the other hand results in very poor performance.

Why does Collision.getContacts to return only one collision point between a sphere collider and a cube collider? What other way could I use to achieve this kind of effect?

Contact points are not to define an intersection boundary which is what you seem to want it for. They are defined by the physics system based upon the collider geometry and intersection and are used to separate colliders. They effectively define the point or several points at which an impulse(s) will be applied for solving the contact.

In your image above you’d have an infinite number of contact points to define a boundary. You’ll need to calculate that yourself as it isn’t the job of the physics system to do so.

You might find this has some useful links:

1 Like