playMaker

Author Topic: Operate on an public variable from Playmaker  (Read 2538 times)

wrongtarget

  • Playmaker Newbie
  • *
  • Posts: 5
Operate on an public variable from Playmaker
« on: January 23, 2015, 08:59:51 PM »
Hello,

I was showing a friend how could you modify a public variable in a .cs file from a Playmate FSM, and realized how convoluted is the way I'm going through it. I'm wondering now if there's a better way.
Basically we have this C# script that has a public int variable called Score.
What I want is for certain action in a state to ADD 20 to that variable. I thought that Set Property would do it, but of course, set property doesn't allow operators, it just set the value to 20.

So I had to Get the property, store it in a Playmaker variable, then use the int operator action from Playmaker to add 20 to that playmaker variable and then Set the Score property = playmaker variable value.

it seems like a lot of actions to do a simple operation. Is there a better way?
Thanks!

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Operate on an public variable from Playmaker
« Reply #1 on: January 23, 2015, 09:07:39 PM »
"Is there a better way?"

Sure is.  You write a action for playmaker to do that.  Then just plug in the values.

wrongtarget

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Operate on an public variable from Playmaker
« Reply #2 on: January 23, 2015, 09:19:37 PM »
I should had said with the current Playmaker actions :P Haven't got into writing actions yet.
So that'd be the only way to  do it with the default Playmaker actions then?
« Last Edit: January 23, 2015, 09:31:27 PM by wrongtarget »

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Operate on an public variable from Playmaker
« Reply #3 on: January 23, 2015, 09:38:42 PM »
I'm not an expert, but I say you got the way to do it.  Someone else may have a better way.