Jump to content
  • Advertisement
Sign in to follow this  
Quat

turning switches / doing actions

This topic is 4004 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!