Hi
Firstly: yes this is homework, and I'm sorry for asking for such basic help but I'm really struggling here with collision detection and I'm very pressed for time (tomorrow @midnight GMT is my deadline :|).
I have a node representing a room, in which there are several pillars. A pillar is a cylinder with setIsCollidable(true) and setModelBounds(new BoundingBox()).
I also have a player Node (which contains a camera node) which moves around the room. I am trying to get the player node not to be able to walk through the pillars. The player object has setIsCollidable(true) and model bounds set. It is controlled by the keyboard.
I am trying to implement this first with the step forward method and then I will roll this out along the other movement methods.
This is the code which moves the player forward:
private class KeyNodeStepForwardAction extends KeyNodeForwardAction {
public KeyNodeStepForwardAction() {
super(player,movespeed);
}
public void performAction(InputActionEvent evt) {
super.performAction(evt);
player.setModelBound(new BoundingBox(player.getLocalTranslation(),1,1,1));
for(Spatial s:lab.getChildren()) {
if(player.hasCollision(s, true))
System.err.println("t- collided with "+s.getName()+"!");
}
}
}
The pillars are attached as children to the lab object mentioned in the code (the room is our compsci lab).
My test routine is to start the game and make the player walk through a pillar while watching System.err waiting for an error to pop up and tell me there has been a collision. So far I have not managed to remove the player's godlike ability to walk through solid pillars :(
What am I doing wrong, can anyone help?
Many thanks for any help offered :)