playMaker

Author Topic: How to reactive "not active game obj" in "Do not destroy on load" ?  (Read 223 times)

playmakertester

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Hello.

I'm trying to make an object stored in Do not destroy on load active from inactive when I load the scene again.

I am trying to find the object using Find game object with tag and make it active using Active game object, but I cannot find the tagged inactive game object in Do not destroy on load using Find game object with tag.

Please let me know if there is a way to make the inactive game object stored in Do not destroy on load active.

Weak Interactive

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 33
    • View Profile
Re: How to reactive "not active game obj" in "Do not destroy on load" ?
« Reply #1 on: April 30, 2021, 01:21:46 PM »
Hey,

I've read that it's possible find inactive objects with C#, so there might be an action somewhere for that (not in Playmaker by default). However, it shouldn't be too difficult to work around this issue. I'll list a few suggestions:

1. Attach the inactive object to a parent object and put "Don't Destroy On Load" on the parent instead. Then you can use "Find Game Object" to find the parent object (since it's active), and use "Get Child" to get whichever inactive object you want out of its children.

2. Create a new object with "Don't Destroy On Load" in the scene with the inactive object you want to find, then create a Game Object variable on the new object, and put the inactive object into the variable. Then you can find the new object using "Find Game Object," and then use "Get FSM Game Object" to get the inactive object.

These methods also have the advantage that you only need to use "Find Game Object" once, which can be a very performance demanding action in large scenes.

Hopefully that helps, good luck!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6304
    • View Profile
    • jinxtergames
Re: How to reactive "not active game obj" in "Do not destroy on load" ?
« Reply #2 on: April 30, 2021, 08:10:52 PM »
Hi.
For this case i would use a global (game Object)

or if you have multiple object, make 1 game object (that is also not destroyed) set that game object as a global (call It Meta Data for example)

Then on that 'Meta Data' you can set variables that can hold a reference to those other objects.


then you can use 'Get Fsm Game Object' fsm : Meta Data and  the name of the variable where you stored a object.
Ecosystem might not work at the moment
here are direct Github Links to the custom actions :
https://github.com/PlayMakerEcosystem
https://github.com/jeanfabre


Join the PlayMaker Discord Channel!

playmakertester

  • Full Member
  • ***
  • Posts: 210
    • View Profile
Thank you all!

So this was an issue that everyone was trying to counter.
Thank you.

I'll give it a try.