So here’s the method:
public Act[] Orientate(ActionType type, ActionDirection direction)
{
Act[] orientatedAct = referenceActions[(int)type].acts;
foreach (Act _act in orientatedAct)
{
Vector2 rotatedOrigin = new Vector2(_act.origin.x, _act.origin.y);
if (_act.origin.x > -2)
rotatedOrigin = Quaternion.Euler(0, 0, (90 * -(int)direction)) * new Vector2(_act.origin.x, _act.origin.y);
Vector2 rotatedDirection = Quaternion.Euler(0, 0, (90 * -(int)direction)) * new Vector2(_act.direction.x, _act.direction.y);
_act.origin = new Vector2Int(Mathf.RoundToInt(rotatedOrigin.x), Mathf.RoundToInt(rotatedOrigin.y));
_act.direction = new Vector2Int(Mathf.RoundToInt(rotatedDirection.x), Mathf.RoundToInt(rotatedDirection.y));
}
return orientatedAct;
}
…and for some reason of another, each time I call it, it alters a value within the referenceActions array. referenceActions is a serialized array used for me to define what the actions are. I don’t reference referenceActions anywhere else, so I’m stumped as to why it’s being changed. It seems to apply the rotation to referenceActions[(int)type].acts[0].direction
.
Any help is appreciated. Happy to provide more details.