Newbie question about CollisionDetection with First Person (or Third Person)

ok, I've played around with jME for a few weeks now and I have a few questions that I would appreciate some help with.  Basically, my requirements are as follows:

  • create a 3d world

  • first (or third) person movement

  • collision detection with objects on the root node

  • ability to move an object around in the room if I pick it up

  • ability to put objects in my backpack so I can move them between rooms

  • ability to "enter a room" at which point I'll reload the information about the new room

  • universal inputs (a key is pressed)

  • object specific inputs (a key is pressed when in close proximity to an ojbect of type foo)

That's it for right now... very simple. Basically, I want something that works very much like Wolfenstein. The simple game has most of this except for the collision detection. I know that nodes support collision detection, but all my attempts at incorporating them into the movement of the camera have been kludgy at best.  My requirements are so basic that I'm sure that they've been done before.  I don't want to re-invent the wheel if possible so can someone point me in the best place to start. I've read about the physics engine, but I'm not sure if it was really intended for my situation.

Thanks for your help in advance and keep up the good work... its soooo great to be able to code games in java that look great!

There are lots of references to FPS on this forum just do a search.

As for the physics engine, I believe it's exactly what you're looking for.  It's also quite simple to use.

For example:

PhysicsWorld pw = PhysicsWorld.createInstance();  // Do this in the init

pw.addObject(mySpatial, massOfObjectAsFloat);  // Do this in the init after you have created your spatial

pw.update(tpf)  // Do this in the update

voila, you have physics! :slight_smile:

I would recommend downloading the nightly build as it has much more in it than the current release.


Thanks darkfrog!  I was just reading through the source of the physics engine and it looks like you are correct, it does handle most of my requirements.  Are there any requirements in my list that you see that it doens't handle?  The only question I have about your snippet … what is the mass of object as float?  How would I calculate that for any given spatial?

Also, I'm having trouble checking out the source from cvs because it is saying I don't have permission to view the files.  Is there somewhere else I can get the nightly builds?

You can always download the nightly build from here:

I believe you can't log-in with your sourceforge user/pass to CVS, you have to specify anonymous unless you are a contributor.

Well, there are specific things you are going to have to code such as the FPS looking, which I am going to try to develop some easy method of doing this and hopefully get it committed to the project as this seems to be a very common question.  Everything you want to do is definitely possible to do in jME with jME-Physics but some things will take more code than others.

Good luck,