nikki
26-11-2006 19:23:39
In my game, there is a Crate which the Player can push around. Previously, I made this Crate a rigid body, so that it could be pushed around. But, I realised that it was too realistic, because the Crate needed to move one grid unit (in other words, 'jump' to the next cell-space, like in Chip's Challenge). For this, I made it a static object (a Geometry without a Body). When it collides with the Player, it moves accordingly. I've got it all working, but there are two problems:-
1. It moves into walls.
2. It is does not fall down if there is no floor under it.
All this can be fixed with a cube collision query (place a cube geometry at a position, and check if it collides with anything). To solve the first problem, we do a cube query with the new position, and move if it does not collide. Here is an image (brown = crate, dark gray = wall/floor, light gray = query, green = a little obstacle):-
As for the second problem, we do a cube query one unit under the Crate and fall if there is nothing there.
Regarding alternatives:-
We could do a ray query, but it will not work for the green obstacle example above (of the ray is shot from the head or foot of the Crate).
I also tried moving back if there is a collision, but the space we have to move back to is occupied by the Player, and this method doesn't work for falling.
My question (at last) :-
How do I do a cube query (like Ogre's BoxSceneQuery)?
1. It moves into walls.
2. It is does not fall down if there is no floor under it.
All this can be fixed with a cube collision query (place a cube geometry at a position, and check if it collides with anything). To solve the first problem, we do a cube query with the new position, and move if it does not collide. Here is an image (brown = crate, dark gray = wall/floor, light gray = query, green = a little obstacle):-
As for the second problem, we do a cube query one unit under the Crate and fall if there is nothing there.
Regarding alternatives:-
We could do a ray query, but it will not work for the green obstacle example above (of the ray is shot from the head or foot of the Crate).
I also tried moving back if there is a collision, but the space we have to move back to is occupied by the Player, and this method doesn't work for falling.
My question (at last) :-
How do I do a cube query (like Ogre's BoxSceneQuery)?