Is there a way for a tile animation to be trigger when the avatar enters the tile? For example, I would like for a door to open when the avatar is standing in front if it.
I saw in the the example that you can trigger animations by clicking, rolling over, and rolling out. But I would like to trigger an animation when the avatar walks into the tile. I must also need to implement this for server-side NPCs, so I won't be able to use the onEnterTile function for the server-side.
Tile animation trigger
-
- Posts: 4
- Joined: 18 Mar 2010, 02:58
Opening a door when the avatar walks into a tile is provided in the Ranch example.
In OS you define a tile like the "Sensor 1" one that throws a custom param when entered (OLD_customParams set to "open_the_door" for instance).
The event is caught in the onAvatarMovementEnd() function which receives the "open_the_door" parameter. Just test for this event in the switch and trigger whatever animation you want at that time.
switch (evt.params.tile.customParams[0])
{
case "open_the_door":
/// start the animation to open the door
break;
}
In OS you define a tile like the "Sensor 1" one that throws a custom param when entered (OLD_customParams set to "open_the_door" for instance).
The event is caught in the onAvatarMovementEnd() function which receives the "open_the_door" parameter. Just test for this event in the switch and trigger whatever animation you want at that time.
switch (evt.params.tile.customParams[0])
{
case "open_the_door":
/// start the animation to open the door
break;
}
Bottomless wrote:Opening a door when the avatar walks into a tile is provided in the Ranch example.
In OS you define a tile like the "Sensor 1" one that throws a custom param when entered (OLD_customParams set to "open_the_door" for instance).
The event is caught in the onAvatarMovementEnd() function which receives the "open_the_door" parameter. Just test for this event in the switch and trigger whatever animation you want at that time.
switch (evt.params.tile.customParams[0])
{
case "open_the_door":
/// start the animation to open the door
break;
}
The issue with this is that it's all being done on the server-side using NPCs. So I won't have access the client function onAvatarMovementEnd.
The example provided by Bottomless is based on OpenSpace v1, while I think warhell is referring to OpenSpace v2. Anyway the principle is just the same: in the Editor add an 'avatar stop' trigger to the tile instance in front of the door (and you may also need the 'avatar go' trigger, to close it when the avatar moves away - I prefer the stop/start triggers to the enter/leave tile ones because in this way the door doesn't open if the avatar is just passing in front of it following a path to a different destination). Then listen for the proper event in your client a animate the door.
I don't understand the client/server issue: if you control the NPC on the server-side, you just have to send it to the destination tile (the one on front of the door), then the mentioned events will be fired in all the clients, which will show the door opening in front of the avatar.
I don't understand the client/server issue: if you control the NPC on the server-side, you just have to send it to the destination tile (the one on front of the door), then the mentioned events will be fired in all the clients, which will show the door opening in front of the avatar.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
bax wrote:The example provided by Bottomless is based on OpenSpace v1, while I think warhell is referring to OpenSpace v2. Anyway the principle is just the same: in the Editor add an 'avatar stop' trigger to the tile instance in front of the door (and you may also need the 'avatar go' trigger, to close it when the avatar moves away - I prefer the stop/start triggers to the enter/leave tile ones because in this way the door doesn't open if the avatar is just passing in front of it following a path to a different destination). Then listen for the proper event in your client a animate the door.
I don't understand the client/server issue: if you control the NPC on the server-side, you just have to send it to the destination tile (the one on front of the door), then the mentioned events will be fired in all the clients, which will show the door opening in front of the avatar.
But it looks like you can only add "click", "rollOver", and "rollOut" triggers to tiles.
warhell wrote:bax wrote:The example provided by Bottomless is based on OpenSpace v1, while I think warhell is referring to OpenSpace v2. Anyway the principle is just the same: in the Editor add an 'avatar stop' trigger to the tile instance in front of the door (and you may also need the 'avatar go' trigger, to close it when the avatar moves away - I prefer the stop/start triggers to the enter/leave tile ones because in this way the door doesn't open if the avatar is just passing in front of it following a path to a different destination). Then listen for the proper event in your client a animate the door.
I don't understand the client/server issue: if you control the NPC on the server-side, you just have to send it to the destination tile (the one on front of the door), then the mentioned events will be fired in all the clients, which will show the door opening in front of the avatar.
But it looks like you can only add "click", "rollOver", and "rollOut" triggers to tiles.
I figured out how to do triggers, but how would I grab a reference to the sprite in order to animate it? (the sprite is in the same tile in which the trigger is)
Edit: I re-read through the post and I want to clarify that I want to animate a door opening animation on the tile the avatar has entered, I do NOT want to animate the avatar itself.
Edit again: Alright looks like I figured it out . It looks like you can only put Avatar move/stop/leave triggers on "tile instance" via editing them in the "Map editor" tab. I actually want every instance of a door tile to have a "Avatarmove"trigger. These tiles will not be on the map by default, the user will be able to drag and drop them onto the map. Is there a way to put a tile instance trigger on every door "inventory" item, that will eventually be placed on the map?
Return to “OpenSpace v2 discussions and help”
Who is online
Users browsing this forum: No registered users and 56 guests