playMaker

Author Topic: Get FsmArray values in Custom Actions  (Read 725 times)

Gustav

  • Junior Playmaker
  • **
  • Posts: 53
Get FsmArray values in Custom Actions
« on: March 15, 2021, 05:36:40 PM »
Hi,

I'm struggling with the Playmaker API for hours. Neither in the manual nor here on the forums I have found something that would help me.

I need to get Vector2 values out of a FsmArray variable in code.

After studying a lot of actions I found that I can use the following code to save the array variable to a FsmVar variable

Code: [Select]
storeValue.SetValue(array.Get(index.Value));
but seemingly only if it is public

Code: [Select]
[MatchElementType("array")]
[UIHint(UIHint.Variable)]
public FsmVar storeValue;

After that I can read the value of any variable in the array with

Code: [Select]
storeValue.vector2Value.x
But I don't think that's the right way to use a public FsmVar which is exposed in the editor. It's dirty and complicated.


What is the right way to get Vector2 values out of a FsmArray variable?


Regards
Gustav

Gustav

  • Junior Playmaker
  • **
  • Posts: 53
Re: Get FsmArray values in Custom Actions
« Reply #1 on: March 16, 2021, 06:57:41 PM »
I've found a solution. The type of the FsmVar variable needs to be changed. In my case like this:

Code: [Select]
FsmVar storeValue = new FsmVar();
storeValue.Type = VariableType.Vector2;

@Admins
Please let me know if I can do anything better. :)


Regards
Gustav

Gustav

  • Junior Playmaker
  • **
  • Posts: 53
Re: Get FsmArray values in Custom Actions
« Reply #2 on: March 18, 2021, 07:33:14 PM »
If someone needs this... One can simply convert the array to a Vector4 array (in my case), there is no Vector2 option.

Code: [Select]
Vector4[] _array = array.vector4Values;