Mesh falling through Map

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
GuyOnAWallaby
Posts: 15
Joined: Sat Oct 11, 2014 6:13 am

Mesh falling through Map

Post by GuyOnAWallaby »

I am following one of the tutorials on collision and trying to get it working. I got the camera to work when colliding against objects, but then I tried to load another mesh in and give it gravity, but it fell through the map.

http://pastebin.com/20mmb7Ui

This is basically all the code that deals with setting up the nodes and meshes. Can't figure out why the playerMesh falls through the level. Any help or guidance would be great thanks.

I realize that in the code the playerNode gravity is set to 0, but if set to anything negative, it falls through the map.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Mesh falling through Map

Post by CuteAlien »

You shouldn't create a triangleselector for the player. The CollisionResponseAnimator works by colliding a sphere against geometry. So you add a triangleselector for the geometry - and the sphere is then around the player.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
GuyOnAWallaby
Posts: 15
Joined: Sat Oct 11, 2014 6:13 am

Re: Mesh falling through Map

Post by GuyOnAWallaby »

It is working now, thanks CuteAlien, but I have another question. Can CollisionResponseAnimators not collide which each other? The camera is walking right through a node that has a CollisionResponseAnimator.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Mesh falling through Map

Post by CuteAlien »

Tricky question. You might get that to work in theory - but it's very likely a bad idea. You usually don't use real geometry collisions for dynamic objects colliding with each other in realtime 3D applications. I'm not even sure if it would work when those objects do move. Static objects are no problem - you can add triangleselectors for those and then add them all together into a metatriangleselector. But for moving objects people tend to use simpler algorithms. Like collision spheres (meaning you check for the distance between 2 objects and when it's less than the radius of both involved objects you have a collision). But this kind of stuff is very game specific... different games have very different requirements. And once it get's more complicated than that you might start considering to use a physics engine. Irrlicht collision is nice for quick demos, but more complicated cases are not handled automatically.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
GuyOnAWallaby
Posts: 15
Joined: Sat Oct 11, 2014 6:13 am

Re: Mesh falling through Map

Post by GuyOnAWallaby »

Oh okay, I thought Irrlicht had a game centered collision system in it, any physics engines you would suggest that would mesh well with irrlicht? I know bullets is one.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Mesh falling through Map

Post by CuteAlien »

I would recommend bullet. But really depends on your game if you need that already. I usually get through with distance-checks for the dynamic objects (a lot of games use those).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
GuyOnAWallaby
Posts: 15
Joined: Sat Oct 11, 2014 6:13 am

Re: Mesh falling through Map

Post by GuyOnAWallaby »

I think I'll use bullet since I plan on using it for other stuff as well, thanks for the help.
Post Reply