Archived

This topic is now archived and is closed to further replies.

Moving world objects

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been working on a game for a class and the professor suggested we do collisions by moving all the world objects and then resolve collisions that occur. Well, we''re just about done with this game, and I just want to verify if this is the "correct" way of doing it, or if there is a more efficient way of resolving the situation (for my own personal knowledge). So basically, my question is, in a game loop would you do: move all WorldObjects for all objects vs all objects, if objects collide, and they''re allowed to collide, resolve the collision. ? Thanks! P

Share this post


Link to post
Share on other sites
At a very high level, your loop looks good. Of course, the nitty-gritty details of "resolving" the collision can be tricky. Or not, depending on your game and goals.

There are many possible speedups to the loop. The largest is where you say:

"for all objects vs all objects"

I would say:

"for all objects that are allowed to collide vs all objects that are allowed to collide"

Basically, keep a list of things that can collide, and only check them rather than walk through all objects.

You can also partition the space so that you only check objects that are known to be close to each other, for example:

"for all objects that are allowed to collide vs all NEARBY objects that are allowed to collide"

I realize my expansion of your idea is also at a high level, but hopefully this is helpful.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
By the way, Panayoti, thank you for taking the time to show some of your work. Even though your question was about a homework assignment, it certainly fits this forum. And I''m happy that you did not just blindly ask for an answer.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
You can project the bounding boxes of all objects on
the OXYZ. You get some segments there.
You mark each segment with 2 flags start/end.
Then you do a full sort of the list once.

For each gameloop then you do a partial sort, by walking
in all lists, and just switching if 2 elements
get unsorted.
Then you test O-X for segment overlapping
if you get pairs S-E S-E S-E there are no colisions do you dont have to go on O-Z/O-Y. If there is a misplaced sequence
S-S-E-E you flag the elements to be tested forward on O-Z/O-Y,
then you go on OY and do the same thing. If finally on OZ you get
a overlapping thing the objects are in collision. This technique
eliminates early lot''s of objects and you can perform collisions with many many dynamic objects.
If you get a pair of colided objects then you recalculate the
new positions and go again in the test until there are no coillisions.


MCO

Share this post


Link to post
Share on other sites