Sign in to follow this  
Quat

turning switches / doing actions

Recommended Posts

Quat    568
I'm thinking of final fantasy (old ones) games where your player could go up to a treasure chest, and press a button to open it, or press a button to throw a switch. What is the best way to handle this in a game. Right now I have a messaging system. When the user presses the "action" button, should I send a message to all nearby objects that listen for that message (like chests, buttons, doors) so that they can change their state?

Share this post


Link to post
Share on other sites
newera    157
The way I did it was to call a script upon receiving an event. For example, when a player steps on a switch or opens a door, the entity in question calls a script to see what it should do, if anything. I did this for entering and/or leaving a state.

Player steps on floor switch -> floor switch state goes to down --> the floor switch runs a script if it has one -> script does an action, opens far off door.
...

It makes for a robust system, you can do just about anything with it.

-Tony

Share this post


Link to post
Share on other sites
oliii    2196
Maybe not all entities, just the one you want to use / collect. Send a request message to that entity, and that entity will perform the relevant action (via script or not).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this