Forum: General

Noise and pickup Listeners

Hi!

I'm playing with some listeners like Noise and pickup object listeners and i have a problem.

IWorldEventListener botHearNoiseListener = new IWorldEventListener() {

@Override
public void notify(HearNoise event) {
//escoltar si hi ha soroll pel voltant, d'on ve, com ha sigut produit...
body.getCommunication().sendGlobalTextMessage("Noise source: " + event.getSource().toString());
body.getCommunication().sendGlobalTextMessage("Noise type: " + event.getType());
body.getCommunication().sendGlobalTextMessage("Noise rotation: " + event.getRotation().
body.getCommunication().sendGlobalTextMessage("Noise distance: " + event.getDistance());
}
};

the 2 last code lines (rotation and distance) doesn't work until the bot dies. if i shoot him with the shootgun he dies and i can see the rotation and distance but if i shoot near the bot the rotation is 0.0, 0.0, 0.0 and the distance is 0.

Does anyone know why this happens?
By the way, i initialize them in prepare bot:
public void prepareBot(UT2004Bot bot) {
getWorldView().addEventListener(HearNoise.class, botHearNoiseListener);
}
You mean that event.getRotation() and event.getDistance() are not always filled?

Did I understand that right?

Cheers!
Jimmy
Exactly! they are filled when the bot dies, when he is alive they are always empty

Thanks!

Joan Marc
Thanks xD

Regards, Joan Marc.
Fixed. Code in svn repository.