Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

We're creating an action MMO using Three.js (WebGL) with an arcadish feel, and implementing physics for it has been a pain in the butt.

Our game has a terrain where the character will walk on, and in the future 3D objects (a house, a tree, etc) that will have collisions. In terms of complexity, the physics engine should be like World of Warcraft. We don't need friction, bouncing behaviour or anything more complex like joints, etc. Just gravity.

I have managed to implement terrain physics so far by casting a ray downwards, but it does not take into account possible 3D objects. Note that these 3D objects need to have convex collisions, so our artists create a 3D house and the player can walk inside but can't walk through the walls.

How do I implement proper collision detection with 3D objects like in World of Warcraft? Do I need an advanced physics engine? I read about Physijs which looks cool, but I fear that it may be overkill to implement that for our game.

Also, how does WoW do it? Do they have a separate raycasting system for the terrain? Or do they treat the terrain like any other convex mesh?

A screenshot of our game so far: Ironbane MMO

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

You will likely need some kind of polygon collision detection and reaction. Also, you will need a way to organise it, like in a BSP tree or octree, as a lot of 3D objects will need to be culled when checking for collision or rendering to keep performance.

If this is the way you are going it is going to take a long time, not just to do but to learn if you don't know what you are doing already. The benefits are rewarding but much easier is to use an engine that has all this stuff in it already. Then you just have to learn how to use it.

Goodluck using javascript.

share|improve this answer
    
Thanks, I think for me it would be better if I used a premade physics engine. Just out of curiosity, why do you wish me good luck with javascript? –  Nick Jun 13 '12 at 8:58
1  
@Nick Probably because it has so many quirks... –  Laurent Couvidou Jun 13 '12 at 17:46
add comment

You stated that it will be a MMO game - don't do this kind of stuff client-side. You will have problems with cheaters, because it's fairly easy to modify your code so they can fly/no-clip etc.

If your terrain is heightmap-based just prepare your world so you have all of the objects inserted (houses, trees etc.) and generate some kind of mask which will exclude non-walkable places on the map. Take a look a this example for how it should look like:

example world world's mask

Then on the server-side just check if the user is not on one of the red spots, if so just move them away (or stop movement when they are about to enter one).

To generate such mask you should loop through all of your objects and get their intersections with terrain (for example raycast from every vertex below some height). At least that's how I'm doing it and it works perfectly.

Of course that will work only if your terrain is heightmap-based, so no overhangs, caves etc (you would have to modify it a bit to get it working on multiple heights).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.