playMaker

Author Topic: ArrayListSort with vector3  (Read 1323 times)

JochemB

  • Playmaker Newbie
  • *
  • Posts: 3
ArrayListSort with vector3
« on: April 10, 2018, 11:19:24 AM »
Hello. I’d like to sort the z positions of a vector3 array list. In regular Unity script I do it like:

Code: [Select]
myArray = myArray.OrderBy(pos => pos.z).ToArray();

Now I want to do this in Playmaker, so I thought I’d just modify ArrayListSort to this:

Code: [Select]
proxy.arrayList = proxy.arrayList.OrderBy(pos => pos.z).ToArray();
But that does not work because I can’t access z from pos. What do I need to understand better to have this done?

Deek

  • Full Member
  • ***
  • Posts: 133
Re: ArrayListSort with vector3
« Reply #1 on: April 11, 2018, 03:55:55 PM »
Try
Code: [Select]
pos.Value.z
since your "pos" variable is probably a FsmVector3 and those FsmVariables are wrappers for their original counterparts containing additional extensions and support for their own custom PlayMaker fields.

So on every FsmVariable (like FsmGameObject, FsmString, ...) you access the value of that variable wrapper with .Value, check if it's set to none (in the Action) with .None and so forth.

Once you write pos.Value it behaves like a normal float variable and thus can be modified like one but note that when you want to set/overwrite the value for pos you'd have to also asign the new value to pos.Value.

Example:
Code: [Select]
//store the current value of pos
float tmpPos = pos.Value;
//this won't change the value for pos...
tmpPos += 3f;
//...you also have to overwrite the value of the FsmVector3
pos.Value = tmpPos;
---
//you could also directly set the value without another variable
pos.Value += 3f;