Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: MakeANiceGame on September 29, 2019, 07:06:34 PM

Title: How can i changing prefab's variable - Corgi engine ?
Post by: MakeANiceGame on September 29, 2019, 07:06:34 PM
Hello there,

I'm using Corgi Engine 2D. A pretty cool 2D platformer engine.

The way this engine works is ... the player controller (an actual Corgi :D ) get's instantiated from the prefab at the start of the game.

This Prefab has a couple of scripts on it. I want to change the value from 1 variable in a script. I was able to "Drag and Drop" the script into the FSM & find the actual value, and specify that new value, but of course that doesn't work.

So what's the normal way to approach this?

Thank You
Title: Re: How can i changing prefab's variable - Corgi engine ?
Post by: djaydino on October 12, 2019, 07:49:47 AM
Hi.
You can use Get/Set Properties actions maybe.
Title: Re: How can i changing prefab's variable - Corgi engine ?
Post by: Thore on October 12, 2019, 10:06:02 AM
Drag and drop should work. But if you use a lot of scripts, I recommend taking an afternoon to learn how to write simple getter and setter Custom Actions.  Mdotstrange has tutorials on his channel for that.

They are simple Custom Actions for PlayMaker (using the Custom Action Wizard, you find in the PlayMaker menu in Unity’s top bar), that can either read a variable or write it into the script. It’s pretty simple to do, and really takes only an afternoon to get it it going.

See here...

and...

Title: Re: How can i changing prefab's variable - Corgi engine ?
Post by: ch1ky3n on October 14, 2019, 12:12:06 AM
Try to reverse it by putting the fsm inside the prefab itself. By doing it u can refer the value inside the prefab. When the prefab is instantiated, you can send event on the prefab to trigger the value changes.