Reply To: Can't change a Unity 5 Image

NodeCanvas Forums Support Can't change a Unity 5 Image Reply To: Can't change a Unity 5 Image

#10944
Gavalakis
Keymaster

Hello,

Hmm. Do you mean that the code runs, but the source image is not set? It seems that you are setting the image on each frame, and the Unity UI might not be able to handle that (haven’t tested, but just a speculation). Would a simple Sequencer with a Wait child and an Execute Function of your NewLocation method will work?

Regarding examples, there are some examples available to download. Have you checked them out, or are you referring to something different? 🙂

Comparing variables can be done with the Condition Tasks under “Blackboard” category. For example with the Check Float condition, you can compare floats for equality, non equality, greater, less etc. I am sure I misunderstood this question though since I see you already used one such condition. Can you please clarify what you mean on “how to compare variables”?

The Button and Slider are only some default available types. If you open up the “Preferred Types Editor” window (Tools/ParadoxNotion/NodeCanvas/Preferred Types Editor”), you will be able to alter the list of available types to you desire, by adding new types, or even removing existing ones that you dont like/want to use. All types in the list in that window, will be available to work with in NodeCanvas. So if you want for example, you are free to add the “UnityEngine.UI.Image” type by clicking the “Add New Type” button there. Doing that will allow you to call methods or get/set properties on an Image component directly, as well as have variables of that type in the Blackboard for example.

Finally, if what you are after (as far as I understand), is to change the background of the -I presume- adventure game, then indeed FSMs would be a much better fit at doing that, since each state can represent a different location.
Each state would then have an action to set the image of the background (or even more actions doing other things relevant to the location), as well as transitions from it to other ‘states/locations’ based on some conditions like for example a UI Button clicked, or the player entered a trigger. I would definitely recommend using FSMs for location management.

Please, let me know if you need ANY clarification on the above at all, or if the above works or not for you.

Thank you!

Join us on Discord: https://discord.gg/97q2Rjh