Author Topic: Game Object Switch  (Read 1863 times)


  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Game Object Switch
« on: June 22, 2020, 10:56:48 AM »
like a string switch. it checks if a desired game object is the same as one stored in the switch and sends an event based on that.

currently I need to get the game object's name, then compare it to a dozen strings of other names of game objects. but this means that I need to remember to manage the string switch if I change names of those game objects. this would make it way easier to maintain.


  • Full Member
  • ***
  • Posts: 215
Re: Game Object Switch
« Reply #1 on: June 22, 2020, 11:28:33 AM »
Maybe I don't understand, because I'm wondering why you don't just use Gameobject Compare:


  • Administrator
  • Hero Member
  • *****
  • Posts: 7625
    • jinxtergames
Re: Game Object Switch
« Reply #2 on: June 22, 2020, 01:58:59 PM »
You can place your objects into an array then use 'Array Contains' then store the index.
That index you can then use with a int switch (depending on what you need to do you could also use a 2nd array with some values and get it with the stored index, then you would not need to use int switch)