www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: fireside on March 15, 2008, 12:28:14 am

Title: Collision Listener not working
Post by: fireside on March 15, 2008, 12:28:14 am
I'm not sure if I'm way off base trying to use the Collison Listener, but I have this class as follows:
Code: [Select]
public class Mouse extends Base implements CollisionListener {

public Mouse(Object3D obj) {
super(obj);
// TODO Auto-generated constructor stub
}

private Object3D colObj;

@Override
public void collision(CollisionEvent event) {
colObj = event.getObject();
// TODO Auto-generated method stub

}

@Override
public boolean requiresPolygonIDs() {
// TODO Auto-generated method stub
return false;
}
public void update()
{  if(colObj != null)System.out.println(colObj.getID());
colObj = null;
}

}



In the loop, I have mouse.update();

I walk the mouse around, he collides with things, but the println() command never gets called.
Title: Re: Collision Listener not working
Post by: EgonOlsen on March 15, 2008, 10:34:25 am
Maybe you should add a debug output in the collision-method too...just to be sure. Apart from that: Has the listener been added correctly to the object in question?
Title: Re: Collision Listener not working
Post by: fireside on March 15, 2008, 05:06:53 pm
Is there an example of a collision listener being used anywhere?  I can't quite understand how it was meant to work.

edit: Oh, the car demo has one.  I'll study that for a while.