Collision Detection - FPS style

RandomGamer

26-03-2008 17:22:29

Hey, all

I don't need much for collision detection - no fancy physics, no bouncing - I basically need to make sure that all Entity's bounding boxes never intersect.

I tried looking at Demo_OgreCollision01.py and that showed me how to detect the intersections, but that's kinda late - I need to prevent them from happening in the first place, I'd think.

Essentially, if my dude is running around FPS style, I need him not to be able to run into walls / crates / other dudes

Any insight in doing this before actually moving the Entity's node?

Thanks!

SiWi

26-03-2008 18:21:28

I would say that you should use ogreopcode. You could have the collisions to be always one step further than the visual presentation.
But again this kind of questions should be asked in the main forum. You will get a lot more (valuable) answers there.

andy

27-03-2008 08:04:55

Or in the queryresult function you can simply move the entity 'back' the way they cam a fixed amount (or the same amount they 'last' moved which you could keep track of)..

Depending on your application you know which object are moving, so record their 'last' position before moving them -- if in the queryresult function you see a 'movable' object (hence a collision has occured) then simply set them back to their last position. Worst case you have an overlap for a single frame which depending on frame rates won't be noticable.

Of course this is crude, (and you will have to enable checking and differenet behaviour for movable colliding with other movables etc), however it's simple and will enable you to move on to more interesting and complicated parts of your code :)

Andy

RandomGamer

07-04-2008 02:45:54

Or in the queryresult function you can simply move the entity 'back' the way they cam a fixed amount (or the same amount they 'last' moved which you could keep track of)..

Depending on your application you know which object are moving, so record their 'last' position before moving them -- if in the queryresult function you see a 'movable' object (hence a collision has occured) then simply set them back to their last position. Worst case you have an overlap for a single frame which depending on frame rates won't be noticable.


Just FYI to anyone following this, I did this and it is working fine

Code on request

Entropai

07-04-2008 08:07:33


Just FYI to anyone following this, I did this and it is working fine

Code on request


Interesting, I worked out something with Newton and it works althought its not pretty. Did you use intersection queries? How well is it performing?

RandomGamer

07-04-2008 14:56:15


Just FYI to anyone following this, I did this and it is working fine

Code on request


Interesting, I worked out something with Newton and it works althought its not pretty. Did you use intersection queries? How well is it performing?


Yes, I'm doing intersection queries and it is thus far performing well. The next step in my process will be to get a bunch more objects in and that will be the critical test - right now, I've got a single room (and that only has two walls, a floor and a ceiling), the player object and a ninja for collisions.

When I get a bunch of rooms and some scattered objects, that'll be the real test, performance wise.