playMaker

Author Topic: Prefab retains properties of last created prefab and not a new one  (Read 1315 times)

Infamous

  • Playmaker Newbie
  • *
  • Posts: 24
Hello there-

I tried searching for answers with no luck.

I have a prefab (building) that gets created when a player tries to build.

The prefab has 2 children, child A and child B. At start Child A is active and Child B is inactive.

I am referencing objects  to activate  and deactivate  through local fsm variables and sets those inside  the global controller upon request to show child B and Hide child A.

The issue happens when I try to create another prefab after I show child B and hide Child A.

The new instance shows up with Child B showing and child A hidden. It also retains some local variables from the last created instance.

Sorry if this is not clear or a beginner question. But I tried many things and couldn’t figure out why it’s cloning the last instance instead of the actual prefab. Is it because the prefab is creating the prefab? If so is there a different action I should use instead of a “create gameobject” ?

I would appreciate all the help

Thanks
« Last Edit: October 01, 2019, 07:07:48 AM by Infamous »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Prefab retains properties of last created prefab and not a new one
« Reply #1 on: October 01, 2019, 08:47:02 AM »
Hi.
Can you show how you are creating the prefab as normally when creating a new prefab it should have the default settings.

Infamous

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Prefab retains properties of last created prefab and not a new one
« Reply #2 on: October 01, 2019, 09:56:45 AM »
Hello there- I solved the issue by sending  an event to an empty game object fsm and that creates the prefab.

As for your question, inside the “prefab”  there is an  object when you click on it it triggers  creat object action and the object is set to the prefab.

However upon inspection during gameplay the value for what object to create is changed to the parent not the prefab.

I really would like to find out if there is a way to have a prefab create a prefab not a clone of self.

If this is not clear please let me know if a screen capture is better or not.

Thanks

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Prefab retains properties of last created prefab and not a new one
« Reply #3 on: October 01, 2019, 07:35:55 PM »
Hi.
When you create it will always be an instance(clone) from an object, but you can show some images on your setup so we can see whats going on

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: Prefab retains properties of last created prefab and not a new one
« Reply #4 on: October 02, 2019, 05:01:12 AM »
That sounds a bit complicated. I may also read this wrongly but it almost sounds like you try to create a prefab at runtime. Odd.
Are you using an action like "Create Object"? I don't know but maybe your issue occurs because you try to create an object with a FSM that belongs to a prefab and, for some reason, may automatically use the prefab (the owner of the FSM) as the model to follow.
I admit I don't really understand what's going on.

Infamous

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Prefab retains properties of last created prefab and not a new one
« Reply #5 on: October 04, 2019, 04:04:42 PM »
For anyone who may run into this problem it seems like the solution is to have an empty object create your prefabs and just have your prefabs trigger that event.