Page 1 of 1

Detecting avatar movement stopped near friend avatar?

Posted: 07 Feb 2012, 23:49
by harlanji
Hi,

I have been searching the boards for a while looking for how to detect when an avatar has stopped. It seems that I can do it with onMovementStop on my sub-class, or AvatarEvent.STOP_MOVEMENT if I have a trigger location. Perhaps there is another method I've overlooked? Neither of these seem to quite meet my desire:

What I would like to do is have a "high five" action, where a player's avatar walks over to another avatar and then gives it a high five. I realize one way would be to not allow high five to happen unless the avatar is already in position, and skip the automatic walking, but we are trying to have very simple interaction.

So drilling down, when the high five action is triggered (eg. clicking on friend avatar), I want to:
1) find target position, friend's location but with y+1
2) if there, just do it (ie. play some animation), done
3) if not there, walk there and add a listener for movement stopped
4) when we're there (listener triggered), remove listener, do it, done.
Note) I've simplified, but I want robustness such as following the friend if they've moved, or aborting if they've signed off, but these aren't the issue :)


onMovementStop could possibly be made to do what I want if I make it dispatch an event, and that's okay, but I feel like I'm going against the grain with that and am hoping for a more natural solution.

AvatarEvent.STOP_MOVEMENT seems to require a trigger at my destination tile, which it seems can only be added at runtime via inventory items?

I am open to suggestion for how to achieve this type of behavior to detect when an avatar has arrived at a dynamic position.

Thanks & regards,

Harlan

Posted: 09 Feb 2012, 10:42
by Bax
The AvatarEvent.STOP_MOVEMENT is fine, but it requires you to add a trigger to all the tiles in the Editor.. not very practical.
So I think the best way is to go with onMovementStop on the Avatar class.