playMaker

Author Topic: Game Object Switch  (Read 395 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 274
    • View Profile
    • 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.

daniellogin

  • Full Member
  • ***
  • Posts: 215
    • View Profile
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: https://hutonggames.fogbugz.com/default.asp?W488

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 5945
    • View Profile
    • jinxtergames
Re: Game Object Switch
« Reply #2 on: June 22, 2020, 01:58:59 PM »
Hi.
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)