# Irregular shaped obstacles repulsion fields

This topic is 2797 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do I setup a repulsion field from obstacles that have irregular shapes?
My first thought was to use a bounding box and use its half-radius to calculate.
Thanks
Jack

##### Share on other sites
You can define the repulsion field as a potential based on distance to the obstacle, regardless of its shape.

##### Share on other sites
Do you just want A repulsion field, or one that matches the shape of the object? If just any old field would work, a bounding box or spherical field would be fine.

For something that matches the shape of the object more, maybe have a minimal bounding box to prevent clipping, but also do a few raycasts on the geometry to estimate the closest point. Then repulse based on the closer of the raycasts minus the minimum approach distance or the minimal bounding box. This means the repulsion field of certain bits of the geometry may stick out beyond the bounding box.

##### Share on other sites
I would agree that it might be more efficient to use a distance-based, per-agent approach (i.e. with collision raycasts) than to calculate and pre-bake a repulsion field.

##### Share on other sites
One trick I've found useful at times for creating collisions or physics effects on irregular objects without turning on per triangle collisions was to just child several small collision boxes to the main object. As long as this object is not being affected by it's own irregular shape this works very well and is usually efficient code wise.

If the object has to react physically because of it's irregular shape (for example our repulsion field is attached to half bum bell like shape and has to roll/bounce down a hill while repulsing) then the only clean solution is to create a collision mesh.

Is your fields repulsion strength based on distance or simply on collision? If on distance, you might want to create two or more repulsion nodes that add up each others repulsion vector. That way a peanut shaped repulsion field will not be weaker if you bump into the ends compared to the middle.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 23
• 39
• 75