Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: blackant on May 17, 2019, 06:55:33 AM
-
Hello,
for my game in need to have multiple arrays, and it pose me a problem because of this:
- my character takes the information from a gameobject, wich store objects created by user in an array.
- the character get this array length, into it's own array, to get gameObjects created and decine wich one he needs after.
- to store the others informations in would like to get other informations from the gameobjects from the array itself, and another one wich is the distance from the character to the gameobject.
- so i modified the existing action " Add Range" following the logic, i get the length of the other array, and set it to this one
but the thing is that it doesn't really work and i don't know why.
The first action get the length, set to 1
the second action and range to 0
the third action add range to 1
so there is a difference from one action to the other and no error displayed anywhere, so it's a problem of logic for me…
can someone help ?
-
here is the modified code:
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Array)]
[Tooltip("Add values to an array.")]
public class ArrayAddRange : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Array Variable to use.")]
public FsmArray array;
public FsmInt RangeLength;
[RequiredField]
[MatchElementType("array")]
[Tooltip("The variables to add.")]
public FsmVar[] variables;
public override void Reset()
{
array = null;
RangeLength = 2;
variables = new FsmVar[RangeLength.Value];
}
public override void OnEnter()
{
DoAddRange();
Finish();
}
private void DoAddRange()
{
int count = variables.Length;
if (count>0)
{
array.Resize(array.Length+count);
foreach(FsmVar _var in variables)
{
_var.UpdateValue();
array.Set(array.Length-count,_var.GetValue());
count--;
}
}
}
}
}
-
well… i'll use Array.Resize instead
-
i fund my problem was that i had let an additional add array somewhere else... ::)