playMaker

Author Topic: Unable to set/edit FSM variable  (Read 1205 times)

Aaddiction

  • Full Member
  • ***
  • Posts: 169
Unable to set/edit FSM variable
« on: July 03, 2022, 06:51:01 PM »
I have a custom action with float variables, but it seems I cannot set the variables. I see them in the action, but I cannot assign a global variable to them. The 3 lines on the right are missing.

I wonder what needs to be added in the script so the variables can be edited.

Code: [Select]
public float throttle = 0f;
public float brake = 0f;
public float steer = 0f;
public float handbrake = 0f;

When I change float to FsmFloat I get:

Quote
Argument 1: cannot convert from 'HutongGames.PlayMaker.FsmFloat' to 'float'

Apart from floats I also have a GameObject in the scene that contains the script with those values, so I need to assign it to the action as well. But I don't have 3 lines at the right so I cannot set a gameobject variable to the action. The only way is to manually drag the object from the scene, before playing the scene, which is not desired, since every time the object is different.
« Last Edit: July 03, 2022, 07:13:38 PM by Aaddiction »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Unable to set/edit FSM variable
« Reply #1 on: July 03, 2022, 09:12:50 PM »
Hi.
The floats Should be an fsmFloat variable type.

then use them in this way : throttle.Value inside the rest of you code.

Have a look to some existing actions to understand how they work :)

Aaddiction

  • Full Member
  • ***
  • Posts: 169
Re: Unable to set/edit FSM variable
« Reply #2 on: July 04, 2022, 03:33:07 AM »
Trying but still getting the error above.
How to change that so it works with Fsmfloat?

Code: [Select]
throttle = Mathf.Clamp01(throttle);

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Unable to set/edit FSM variable
« Reply #3 on: July 04, 2022, 08:02:56 AM »
Hi.
it should be :

Code: [Select]

[UIHint(UIHint.Variable)]
        [Tooltip("Float variable to clamp.")]
public FsmFloat floatVariable;


        [Tooltip("The minimum value.")]
public FsmFloat minValue;


        [Tooltip("The maximum value.")]
public FsmFloat maxValue;


Code: [Select]
floatVariable.Value = Mathf.Clamp(floatVariable.Value, minValue.Value, maxValue.Value);
have a look at the float clamp Action :)

Aaddiction

  • Full Member
  • ***
  • Posts: 169
Re: Unable to set/edit FSM variable
« Reply #4 on: July 08, 2022, 08:36:21 AM »
I managed to get it working when I manually in-game set the values.

But the values reset themselves in play mode when I try to use FSM local or global varaiable. I mean I set them with a global value, but when I enter play mode it removes those values and defaults all of them to 0.

I cannot attach images here any more for some reason, so I cannot show with pictures.
« Last Edit: July 08, 2022, 09:05:59 AM by Aaddiction »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Unable to set/edit FSM variable
« Reply #5 on: July 08, 2022, 01:09:07 PM »
Hi.
You can use imgur or something similar to attach images.

There must be something wrong with the code.