Collision advise for FPS game.

I have been playing with panda3d for a few weeks and finally decided to make a simple first person shooter game.

Here is a sample of my progress as of a few days ago (3rd person camera was for debugging). Since then I have been able to make arrows fly through the air and players die / respaun(spelling?) when hit.

In the above sample I use PhysicsCollisionHandler() for everything. I feel I have a good grasp on how this method works and am confident I can easily implement bullets, grenades, fall damage etc. There are a few problems I have with this system:

  1. It requires alot of resources.
  2. I have not figured out collision with geometry from an egg file. (I am sure this will be a large performance hit)
  3. Actors would require several collision spheres for “hit boxes”

I have also created a similar application using treeform’s FPS script awsd+jumping wall sliding script and mouse picking which has much better performance and already works with egg file geometry. The problems I have with this method are:

  1. I don’t know how to stop the mouse picking collision ray with its first collision. (I don’t need it colliding with everything on the other side of a hill or on the other side of a player.)
  2. I am not sure the best way to simulate physics for arrows, grenades, explosions and fall damage.

I am looking for some advise on which system I should use or if there is another option. I would also appreciate any help with some of the problems listed above.

Panda’s integrated collision system same as the physics system are both rather for smaller things, like triggers and small, non-gameplay relevant physics.
With ODE, bullet, physx or any other third-party library you have algorithms specialized on a few tasks, which makes them way faster and, in some cases, easier to use.

As for me I also found ODE’s physics easier to use than Panda’s ActorNodes (has nothing to do with Actors). Still, haven’t tried out the other implementations, that are mostly lurking around the forums.

My idea for your mouse picking problem:
Put a collision plane in front of the camera at the maximal distance you want your picking ray to go. Then you can check if your ray hits that wall and if it does, you simply ignore that event.

2. I have not figured out collision with geometry from an egg file. (I am sure this will be a large performance hit)

this is true just for Polyset colliders - you may specify there any collider polygon panda got to offer (sphere, tube etc…)

3. Actors would require several collision spheres for “hit boxes”

depends on your accuracy expectations - you could have nice results using just few Tube colliders and then check the impact coordinate - spheres are the fastest and more reliable collider anyhow

1. I don’t know how to stop the mouse picking collision ray with its first collision. (I don’t need it colliding with everything on the other side of a hill or on the other side of a player.)

download here my sample package and check advanced level->step1.py

2. I am not sure the best way to simulate physics for arrows,

check advanced level->step3.py from the package above

I dug just panda3D collisions and I found pros and cons there. I’m looking forward to try ODE but actually I heard of major bugs to fix for panda3D 1.7 so I guess I’ll do later but ODE is the best panda3D got to offer for fancy physics without any doubt

Thank you both for your input!

Here is what I finally decided to do:

I based my player movement is based off of FPS script awsd+jumping wall sliding script then instead of doing mouse picking I choose to use the PhysicsCollisionHandler() and create projectiles.

Now I have the best of both worlds in my opinion. My player movement is as you would expect in any FPS game and my arrows and bullets obey physics and are destroyed once they hit something.

While ODE is more feature rich I think it would be overkill for my project.

How is that overkill? You have the same amount of lines in your scripts, if not even less. ODE surely is feature rich, but that doesn’t mean you have to use its whole complexity. It’s suited well also for small things, IMHO.

can you give me the download link for that? It looks like a very good script… It could help me with loads of coding. Ty!

Usually I hear that a general collsion system is better to use for things like projectiles and player collisions than a physics engine.

Is that not the case here? Is ODE fast enough for all of your collision needs?

In ODE there is a separation of the concepts of collision which is represented by ODE “geoms” and physics which is represented by ODE “bodies”.
It is possible to use ODE’s collision system without invoking any kind of physics calculations at all.