Jump to content
  • Advertisement
  • entries
  • comments
  • views

Automating Action & Reaction

Sign in to follow this  


[font=inherit]Automating Action & Reaction[/font]

A tale of candy distribution.




[font=inherit]Most games can be reduced to a series of actions and reactions. Today I would like to share with you a way to facilitate iteration and expansion of these interactions. It will sound obvious to a lot of people but I would have loved to see this kind of example 6 months ago. When I was not yet used to component based mechanics.[/font]

[font=inherit]It all started with a simple request a few months ago, we had just designed & implemented the scoring system and we needed items in the game world to be able to give points when activated. Easy, I wrote a small script which would be attached to objects that had to add points when activated. Controlled by our item's base class, it would be called automatically.[/font]

[font=inherit]The buildup[/font]

[font=inherit]As time went on, that simple "points giver" script was updated to include various behaviors like prefab spawning, door unlocking and so on. It worked well but it was not very flexible. So I changed the structure to include a parent class to have a common entry point and place each behavior in a child class.[/font]


[font=inherit]It's not standard notation but you can see the rewards and the items have a base class, and only these base classes interact with each other. The same kind of effect could be achieved with interfaces but I prefer to have a default implementation.[/font]

[font=inherit]The true power of this structure lies in the modularity. Every trigger or actionable item in the game works with any reward and you can place any number of reward in a game object. The most basic action/reaction you can do is simply "collider - trigger - reward". The player walks in the scene and something happens (tutorial message, cinematic, ...).The possibilities are exponential and a new reward behavior is very easy to add.[/font]

[font=inherit]Polish & additional features[/font]

[font=inherit]Over time, features were added. Like the possibility to set a delay between the action and the reward. Camera travelling firing rewards at event points... What started as a joke -"reward" as in skinner boxes- is becoming a running gag: we'll call this one "reward_kill_player".[/font]

[font=inherit]I recently did the same kind of structure for visual effects. A few key points (creation, destruction, hit, ...) are exposed via a base class. You just have to derive from it and you get all the hooks that an artist would need to handle animations or particle effects.[/font]


[font=inherit]The system is currently powerful enough to allow our designer to create our whole in-game introduction & tutorial with only the reward system. Looking back my only regret is that this system was not put in place earlier to have more of the game relying on it. Also, calling it "reward" when it's in fact a "reaction" was a bit shortsighted.[/font]

[font=inherit]I can share some sample code if some of you are interested. I leave you with one of the more complex interaction that we can produce.[/font]



P.S.: As a very tangible reward after a long wait between news here's a few free gifs. Both features were added this week:


- One of the first iteration. Nothing special...




- One of the last iteration. Circular pattern, grows from the middle and not all of them at once.



[font=arial]- Black mist that will block your path (first iteration, polish will come later)[/font]


Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!