0
Answered

Accessing Variables in other object

Gadget Kk 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 1

Hi everyone,

So 2 new questions...

  1. Is there a way to access an object variable from a different object, or does it have to be set at the scene level or higher?
  2. I have an object that get instantiated by pressing space and that object, then in turn, instantiates another object (fireball creates a smoke particle effect object). I can get the fireball to instantiate the smoke effect, but i can't figure out how to have the smoke object follow the fireball object. And since there may be several fireball objects, i can't tell it to just follow the fireball object.

Thanks in advance for any help.

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Answered

Hi Gadget!

  1. Sure! Just pass the other GameObject with the variables component to the Target input on the Set Variable unit.
  2. Two ways here: the easy one is just to make the smoke effect a child of your fireball, either through your prefab before hand or by calling Set Parent as a unit. Or you can create a follow script on the smoke effect manually. The trick here is to pass the "parent" fireball after creating the smoke effect; for that you can just use the technique in question 1 ^ . :)