playMaker

Author Topic: Best practices for dealing with about 80 clickable objects?  (Read 1803 times)

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Best practices for dealing with about 80 clickable objects?
« on: February 11, 2015, 07:35:05 PM »
I have about 80 identical objects in my scene. Each one, when clicked, plays a unique sound file and begins a rotation animation. I can easily create this behavior by adding a FSM to one of the objects, but I'm assuming it's bad to just copy that FSM onto the other 79 objects, resulting in 80 unique FSMs? Or...is that ok? Is the idea to somehow do it with a single FSM?

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Best practices for dealing with about 80 clickable objects?
« Reply #1 on: February 11, 2015, 07:46:58 PM »
I would make a template that pulls the appropriate sound from a database and put that one single template on each unique object.

The template could get the name its owner object at runtime, string compare to something in the database and pick the appropriate sound to use. Then if you had to change anything you could do it all in one template and affect every object rather than having 80 objects that you have to fix.

Much more maintainable that way.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: Best practices for dealing with about 80 clickable objects?
« Reply #2 on: February 11, 2015, 07:53:21 PM »
Ah ok, thank you. So...one thing I don't understand...does the usage of templates improve performance, or is it just a convenient way to copy an FSM? In other words, if I have 80 FSMs generated from a single template, in the end is that the same as not using templates in terms of game performance?

I read that having a low number of FSMs is good, (like less than 5), and I'm not sure if I'm being overly cautious about that.
« Last Edit: February 11, 2015, 07:57:12 PM by indeed »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Best practices for dealing with about 80 clickable objects?
« Reply #3 on: February 11, 2015, 08:06:40 PM »
If you have 80 objects and needs FSMs on them all then there isn't much way around that. If you're concerned about performance that much then you could have one fsm that checked to see what was clicked and then played the appropriate sound and rotated the clicked object, that would probably be the most efficient way to do this but the switch list would be pretty huge.

A template is like a Prefab FSM, it is instanced at runtime so each one is still its own unique FSM at runtime but in the editor it is treated like a prefab.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Re: Best practices for dealing with about 80 clickable objects?
« Reply #4 on: February 11, 2015, 08:09:38 PM »
Ah ok, that makes sense. Thank you for the explanations!