Dont run into walls?

Hello everyone,

  I am making a simple maze game. I setup the maze using quads. I also setup collision detection for outside walls and roof. However, I want to make it so the camera cannot go through quads. Is there some collisiondetection function in jME? Thanks!

if u r using chasecamera, just update the camera's position in the update method so when it has collision with the wall nodes, set it position to the old one.

My game has a similar maze. To avoid the overhead of the collision detection with the walls, I hold an array of "allowed" places, and call a slide method in the update method of the controller, which basically pushes the node back if it comes too close to a "not allowed" field.



The code may look a bit lengthy, but is robust and much easier than true "sliding". Of course the sliding implemented here follows just the "grid" not the real shapes, but for a maze this is normally what you want.



public final static Position[] NEIGHBORS = new Position[]

Thanks for the code Landemi, but I never setup a 'grid' for my maze, its just a bunch of quads that I setup. I setup a bounding sphere for the camera, and have it move with the camera, is there a way to check if the sphere hits a wall? if(boundingSphere.collision){} ? Thanks again!

jmetest.intersection.TestCollision does that, only with BoundingCapsules, where you would need a BoundingBox and a BoundingSphere. The procedure is just the same in that case.

Here is my collision check between my player and another node, e.g. an evil robot…



    //somewhere in my hierarchy for moving objects, there is a member variable "node"

    public boolean checkPlayerCollision() {
        Node player = ...  //just a node with a bounding volume around the player
        if (player == null || player.getWorldBound() == null || node == null || node.getWorldBound() == null) {
            return false;
        }
        return node.getWorldBound().intersects(player.getWorldBound());
    }