Tile animation trigger

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

Moderators: Lapo, Bax

warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Tile animation trigger

Postby warhell » 31 Mar 2010, 18:24

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.
Bottomless
Posts: 4
Joined: 18 Mar 2010, 02:58

Postby Bottomless » 31 Mar 2010, 22:53

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;
}
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Postby warhell » 01 Apr 2010, 01:36

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.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 01 Apr 2010, 07:05

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.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Postby warhell » 07 Apr 2010, 17:49

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
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Postby warhell » 07 Apr 2010, 18:20

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?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 07 Apr 2010, 19:13

Actually this is a limitation of OpenSpace 2: you can't have avatar triggers on inventory items. Sorry.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Postby warhell » 07 Apr 2010, 20:22

bax wrote:Actually this is a limitation of OpenSpace 2: you can't have avatar triggers on inventory items. Sorry.


:(

Is there any workaround for this?
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 12 Apr 2010, 16:22

Unfortunately not. We will take this suggestion into account in future improvements.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 49 guests