playMaker

Author Topic: Trying to run leantween on a prefab from a prefab  (Read 554 times)

mallenroh

  • Playmaker Newbie
  • *
  • Posts: 31
    • View Profile
Trying to run leantween on a prefab from a prefab
« on: September 10, 2017, 09:32:06 AM »
Hi, I know instantiated prefabs can't interact with scene objects, but I'm trying to run a leantween action on a prefab from another prefab. I still get the null reference exception, object reference not set to an instance of an object error message.
I even used find game object to find the prefab , but it still won't work.

Deek

  • Full Member
  • ***
  • Posts: 130
    • View Profile
Re: Trying to run leantween on a prefab from a prefab
« Reply #1 on: September 10, 2017, 11:43:39 AM »
The first sentence is wrong, instantiated Prefabs can interact with any scene object if you give your actions inside that Prefab a GameObject variable and set the GameObject outside of that Prefab (either by using Global Variables or 'Set Fsm Game Object'); and that's also how you should proceed.

You can't call or modify a Prefab directly at runtime (they are completely encapsulated from the outside world), that's why you have to create an instance of that Prefab and then you can do whatever you want to/with that instance.

For example: You could use 'Create Object', set the "Game Object" to the first Prefab, under "Store Object" you use a Global Variable and then you can use that variable in your other Prefab after you spawned/created the instance.