playMaker

Author Topic: Using variable to change a sprite [SOLVED]  (Read 1580 times)

robbiew

  • Playmaker Newbie
  • *
  • Posts: 3
Using variable to change a sprite [SOLVED]
« on: April 19, 2017, 06:24:26 PM »
After a bit more playing around, I figured out how to use a variable to change a Sprite.

- Get FSM variable
- Convert Int to String (save to new variable)
- Hash Table get (with newly converted string variable) -- but the RESULT needs to be an "object" type set to Unity Engine > Sprite -- there is not "Sprite" type in the top menu options! Save that to a variable.
- Set the property of the object sprite with this new variable.

Viola!


-----------
New Playmaker user here!

I'm trying to use a global variable to determine which sprite is to be used on a canvas, and swap the current sprite out for this new one.

I have a global int variable called "current_location" which gets updated in another script based on certain user actions. There are 0-100 locations.

I have an ArrayMaker hashtable that contains the sprites, each key value corresponding to a current_location value (e.g. 0 key = 0 variable)

I use INT CHANGE action to see if current_location value has changed.

If TRUE... this is where I'm confused. I know I need to match the key value to the global variable, then set the hashtable's sprite to the game object.

But how? Any hints? I sort of feel like I'm missing something fundamental here.

Thank you for any help!
« Last Edit: April 19, 2017, 07:51:18 PM by robbiew »