3D collision

Hey! This is the first post I’ve had on the codea forums but I have been using it for probably close to a year now. Im working on making a game like Cube World for iPad in codea, I’ve got a lot of 3D knowledge and have done a lot in 3D. At the moment my game consists of parts of the character model and a blocky terrain generator powered by noise(). I’ve gotten really far with this game and worked for many hours on it. But I’m coming up on a part that’s got me a little worried… 3D collision, I’ve made a project for 2D collision that works very well and I have implemented it in some of my other 3D projects for setting borders. But I feel like the way I made my 2D collision very inefficiently, I did it by comparing the position given to the box positions set as things you could collide into. I did it without using the physics part of codea at all, and now I’m wondering if that would be better, and if I do go the way that I did with my 2D collision I think it is going to involved at least 4 times the code >.< I’m just wondering if there is a easy way of making 3D collision or if I could easily implement the physics module into it. Thanks for reading through my novel of a post xD any advice or help would be appreciated

If you’re only travelling in one direction then you can use box2D as you negate one axis of movement, leaving you with a 2d surface. Although 3D collision is hard, there are many lua libraries already out there that handle 3D collision of meshes/objects. I would stick to using a custom physics engine, even though box2D will be faster you make a game 3D so you can move in all directions.

Ok, so if I’m reading this right, create my own custom physics engine because my game involves multiple axis.

@Peary if you’re not using using all 3 axes then use box2D. Even a flat 3D environment can use box2D with a basic bottom z check to see if the player is touching the ground and then the walls are box2D physics bodies as well the player (or you could just use a graphic with physics.raycast if you’re feeling a bit custom). But if you heavily depend on movement in all 3 axes being the same in terms of collision, go full custom.

Ok, thanks for your help!!

@Peary - I had a go at 2D collisions without the physics engines here
http://coolcodea.wordpress.com/2013/10/24/129-physics-collisions/
which may be of some help, I don’t know

3D collisions are definitely hard though. Luatee’s suggestion of reducing them to 2D if possible is a good one!

@Luatee @Ignatz Google “Cube World,” it uses all 3 dimensions.

@SkyTheCoder I did but he said Cube World for iPad, I could only find ‘Cube’ for iPad. I’m thinking you could still use box2D but it wouldn’t be neat.

@Luatee I think he meant Cube World for PC, and that he was trying to make an iOS version.