moveMyAvatar while moving

Post here your questions about the OpenSpace 1.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Post Reply
LEAn
Posts: 16
Joined: 21 Aug 2008, 11:01

moveMyAvatar while moving

Post by LEAn »

I need user avatar to stop 3 tiles before paticular tile (target). To do this I
1) send moveMyAvatar with the target tile.
2) on EnterTile event I'm checking if avatar is 3 tiles or less to the target tile
3) if so - I perform some actions and send moveMyAvatar/teleportMyAvatar with current tile to stop movement. But last moveMyAvatar is not working. it says that
[INFO] Avatar 10 teleporting requested; selected position: (1,10,-1)
[WARNING] Can't teleport avatar 10: invalid position.
I still can go to this tile using mouse, so that is valid tile to go to.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

The target position of the teleport action is considered invalid because the avatar is already on that tile.
What about using the moveMyAvatar to stop the avatar to the desired tile?
Paolo Bax
The SmartFoxServer Team
LEAn
Posts: 16
Joined: 21 Aug 2008, 11:01

Post by LEAn »

Yes, moveMyAvatar does not think current tile is invalid.
[INFO] Avatar 38 movement requested; selected position: (3,8,-1)
[INFO] Starting movement of avatar 38 towards position: (3,8,1)
[INFO] Tile selected: (3,8,1)
[INFO] Pathfinding completed (total time: 0ms)
[INFO] Avatar 38 movement requested; selected position: (1,10,-1)
[INFO] Starting movement of avatar 38 towards position: (1,10,1)
[INFO] Tile selected: (1,10,1)
But it does not move avatar to the second requested tile. It still goes to first one. As I can see pathfinding was not completed.
P.S. (3, 8) is the target tile, and (1, 10) is tile where I've asked to stop.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Sorry, but I'm not following you... can you please describe your actions step by step?
Paolo Bax
The SmartFoxServer Team
LEAn
Posts: 16
Joined: 21 Aug 2008, 11:01

Post by LEAn »

Shure, here is my steps:
1) User selects menu item
2) I'm calling moveMyAvatar with the target tile
3) in handler of ENTER_TILE event I'm checking if current tile is 3 or less tiles to the target. If so - call moveMyAvatar with current tile. This is to cancel previous movement and stop on current tile.

The problem is that in this case avatar still goes to the target tile. And, as you can see from logs in my previous post, seems that this is due to inability to calculate path to the same tile.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

We double checked, and the moveMyAvatar method is not able to stop the avatar on the current tile.
You have to find a different way to do what you need. For example you could check if the avatar is four tiles to the target, and use the moveMyAvatar method to send it to the next tile.
Paolo Bax
The SmartFoxServer Team
LEAn
Posts: 16
Joined: 21 Aug 2008, 11:01

Post by LEAn »

But for this we would need to know next tile of movement and check if it is walkable. As in general it can fail to go to the next nearest tile in some cases.
Post Reply