Advertisement

Oriented rectangles problem

Started by July 01, 2016 06:17 PM
1 comment, last by Irlan Robson 8 years, 7 months ago

Hello, I am working on game, where we use circles as collision bodies. They are fine, but for some objects they are not very useful (for instance 2x6 meters object). Circles are nice, because as the objects are moving towards waypoint and colliding between each other, they slide by the colliding object and continue to the waypoint.

So I started using oriented rectangles as collision bodies, which is a lot more realistic than the circles, but now the objects can stuck behind each other and stay there forever, which is not desirable.

As far as I know I can solve this problem by:

- implement dynamic pathfinding - this will be the best solution, but more challenging

- if unit is stuck behind another, it can slide to left or right (which is kind of a hack in my opinion)

- use capsules, instead of rectangles, but I am not sure if I will have the desired effect

Do you have any suggestions?

You say moving left or right is a hack solution, well actually to me using circles to circumvent the need for better pathfinding is even more of a hack than implementing left/right when they get stuck. Also, if the hack works for your game then it's not always a bad thing. So I'd recommend trying the next simplest solution, see how it goes, and then figure out what next to do.

Advertisement

Use capsules for non-uniform objects and try to push the problem to the physics engine first.

OBBs fit well on objects but sometimes they can decrease the performance of the collision pipeline of the physics engine you're using. They are usefull for static geometry though.

Since you mentioned "units" I suspect this is related to NPCs or so. I recommend using capsules as collision shapes both for the players as well as the NPCs and implement some simple path-finding algorithm for the NPCs.

Sorry, I can't recommend a good algorithm. I implemented A* and mixed navigation meshes some years ago but don't know if it is included in the state of the art package of game AI today. Probably you should take a look in the AI section or start another thread there.

This topic is closed to new replies.

Advertisement