Implementing squad-type game: Collisions/Physics

Just wanted to post to gather some ideas on implementing some features into my game. I realize there can be many ways to do something in Panda and the right way will vary based on my specific requirements, etc.

Basically, it’s a real-time squad type game. You direct a squad of 4-8 actors around a 3d environment. I have implemented camera, char creation, point-and-click movement, basic melee combat, loading map from files, etc. and am now starting to tackle interacting with the environment.

Specifically, I want some options for ways to implement:

  • collisions with walls (so you don’t walk through buildings)
  • characters jumping/climbing/flying to higher ground and then walking on say, a hill or rooftop.
  • making objects (car, trashcan) solid so you don’t walk through them but so they can still be picked

I currently have implemented :

  • actors with collision pushers, so they don’t walk through each other.
  • I can pick actors by clicking them
  • I had turned on collide mask on other objects (bldgs, trashcan) so you don’t walk through them

(yeah not too efficient yet, that’s why I’m posting :slight_smile: )

Have not turned on physics yet, do I need to?
What options do I have to make objects solid but still pickable (saw some posts about octreefy - is that where I should be headed)?


the octree will help thousands of times if you have hundreds of 3d objects you need to collide against…

As far as physics, you could use the physics engine and it would make things simpler, and a little less stable (if using it for your characters movement)

Or you can use ray’s/collision pushers and make the physics yourself, I admit that’s what I’ve been doing as it’s a little more controlled by myself, which I like.

Either way, both will work and there will be different problems you will face, either one will work though

Thanks for the response.

  • On the octree - where is the latest code for that? Is it the one in the thread which mentions a version that is usd at runtime (not rewriting eggs, but used dynamically while app is running?)

  • Also on octree - don’t know a alot about it yet, but can it be used on any model that need collision. i.e. static objects as well as actors?

  • I have wall collisions (by setting the mask) right now, what’s a good way to set up standing on roofs, etc. Would this require rays? or some other collision type object (don’t know them all yet :slight_smile: )

I don’t use physics for movement - so if I don’t need to - I don’t want to implement.

I am not sure on this, but i believe that i saw somewhere that someone (drwr) stated that collision geometry(polygons) isn’t/can’t be animated. You can setup your model with collision solids and attach them to joints to have animated collision model (tubes for hands and legs, sphere/box for head and torso.)

It might be good idea to get nested collision for bullets.
Player is encapsulated in sphere, and first check if bullet hits sphere, if thats true, than go level deeper and check if it hits some body part.

Thanks, some interesting ideas.

I think you’re right that you can’t animate the coll solids.

Anyone have thoughts on the roof standing part? If I set a collide mask on a cube, can I somehow make it so the top of it is solid? i.e. I can place another model on it . Or do I need rays, etc. to detetc collision and the set the model’s Z pos,etc. for this.

I’ll apologize ahead of time if my post makes no sense or something… I’ve a fever and yeah, anyway:

what I did for the avatar’s jumping, falling (gravity), and standing on roofs etc, was pointed a ray downwards from my character, then use a collisionHandlerQueue to sort them and find the closest object, then adjust your Z to that slowly (gravity) so you can be under roofs, or on them, and it works the same. So get the Z from the ray’s closest collision (sorting via the queue, check under the manual for queue sorting)

Thanks! I’ll try that out.