Firstly, thanks for all your suggestions in my other threads, they’ve been very helpful. But on to my next…
While I’m sat here trying to think up the new Tetris, I’m also trying to pre-think the code of the problems I’m creating.
I was playing a 3d pinball game a couple of days ago, it’s definitely model based as the table moves in a dynamic way. This made me wonder how the developer was boundary checking the ball on all the walls, which if course aren’t other spheres.
I have in the past (2d game) had to break collision circles down and use several for ‘long’ objects, is the same done for each face of the table mesh? How do you even get to a face with mg?
I suppose the answers could be similar to a previous post about keeping things on the floor, but in that case I’m not checking the x/y planes for collision or keeping track of angle differences you can traverse and those you cant.
I’m maybe pushing the ability of my brain here, but again if anyone has small samples or tutorials they could pass on I’d really appreciate it.
A physics engine can handle collisions between many different types, cicles/spheres, rectangles/boxes, polygons/polyhedra, etc.
Usually you don’t test against the model mesh, that would be too much work, instead the physics ‘sees’ a simplified collision mesh. 3d model editors have tools to reduce the polygons of a mesh. Or you can hardcover it in code. or write a pipeline importer.
One could always use a cube collision mesh for the ball, it isn’t seen by the player anyway.
Should help simplify the maths as well, somewhat.
Actually no. Using a cube is a very bad idea.
Doing collision checking against a sphere is the simplest collision check of the lot.
All you need is the centre of the sphere and the radis. Then you can do very simple maths to work out the collisions.
After all if the distance of a point from the centre of the sphere is less than the radius, you have a a collision.
Maths for all the common cases is all over the web, sphere box, sphere plane, sphere sphere, everything is there.
But only do it as a learning exercise.
There are many really good physics systems out there and you should be using one of those.
Ya if you don’t use the square root and use the square of the distance i imagine the check would actually be cheaper for a circle.
For the pockets it’s really a interesting case. In this particular case a reversed semi circle would fit the pocket perfectly.
So id use a inverted and angularity constricted inverse circle collision check might take a hour or two to figure out how to write it properly but it would be super cheap and accurate.