playMaker

Author Topic: How can i changing prefab's variable - Corgi engine ?  (Read 2060 times)

MakeANiceGame

  • Playmaker Newbie
  • *
  • Posts: 4
How can i changing prefab's variable - Corgi engine ?
« 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How can i changing prefab's variable - Corgi engine ?
« Reply #1 on: October 12, 2019, 07:49:47 AM »
Hi.
You can use Get/Set Properties actions maybe.

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: How can i changing prefab's variable - Corgi engine ?
« Reply #2 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...


ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: How can i changing prefab's variable - Corgi engine ?
« Reply #3 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.