playMaker

Author Topic: Sending values from a script to Playmaker [SOLVED]  (Read 2809 times)

HiResPharaoh

  • Playmaker Newbie
  • *
  • Posts: 3
Sending values from a script to Playmaker [SOLVED]
« on: November 10, 2018, 11:21:18 AM »
Hello everyone, I am new to C# and to playmaker and trying to make sense of things. I have been trying to pass a value from a script to a playmaker global variable.
The printing to the console works (so I know the aim boolean works) and I have made a global variable in playmaker with the name IsAim of type int, but there is no change to it for some reason. I used a playmaker bool at first but when it didn't work I tried ints based on the state of the boolean called aim instead.
See code below:

       if (aim == true)
        {
            FsmVariables.GlobalVariables.GetFsmInt("IsAim").Value = 1;
           
            print("Setting Aim 1");
        }
        else
        {
             FsmVariables.GlobalVariables.GetFsmInt("IsAim").Value = 0;
           
            print("Setting Aim 0");
        }

Does anyone have any advise on how I can pass that variable to Playmaker successfully?

Thanks
« Last Edit: November 10, 2018, 01:49:18 PM by HiResPharaoh »

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Sending values from a script to Playmaker
« Reply #1 on: November 10, 2018, 11:40:09 AM »
Maybe you can do it the other way around, let Playmaker get the variable, and if needed write into the Globals (probably not needed when you already have it in the script and can get it when needed. You can use Get Property, or probably better, add your own (simple) custom action.  To do this most conveniently, find the custom action wizard tool in the top menu under Playmaker, somewhere in there. MDotStrange in the forum and on YouTube has a simple good explanation on how to write such simple get/set variable actions for your purposes.

Btw, you can write if(aim), which is the same as if (aim == true). False is if (!aim). Also, you should use a bool for the aim as well, rather than 0/1 as off/on.



« Last Edit: November 10, 2018, 01:07:16 PM by Thore »

GonerGames

  • Junior Playmaker
  • **
  • Posts: 53
Re: Sending values from a script to Playmaker
« Reply #2 on: November 10, 2018, 12:12:55 PM »
This shoud work for you:
Make sure you have Using HutongGames.Playmaker at the top
then find and set the Global Value

example:
 
 if (aim == true)
        {
           //find Playmaker global and set as aim variable
           FsmInt aim =  FsmVariables.GlobalVariables.FindFsmInt("IsAim");

           //set aim variable value
           aim.value = 1;
           
            print("Setting Aim 1");
        }
        else
        {
             //find Playmaker global and set as aim variable
             FsmInt aim = FsmVariables.GlobalVariables.FindFsmInt("IsAim");
           
              //set aim variable value
              aim.value = 0;
                       
            print("Setting Aim 0");
        }
« Last Edit: November 10, 2018, 12:20:59 PM by GonerGames »

HiResPharaoh

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Sending values from a script to Playmaker [Solved]
« Reply #3 on: November 10, 2018, 01:46:52 PM »
Many thanks to you both
I think mdotStrange's custom Playmaker actions worked best for me at my current level though. Using his video and scripts here:
http://hutonggames.com/playmakerforum/index.php?topic=13389.0

I managed to grabbed the bool directly from the other script using that code.

Thanks again