Author Topic: Action to get all rigidbodies in children (not working)  (Read 130 times)


  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
Action to get all rigidbodies in children (not working)
« on: April 10, 2019, 10:04:01 PM »
I tried modifying an action to get all Rigidbodies in children from a gameobject, but it is just returning an empty array. I have an array variable of array type 'Object' with object type 'Rigidbody', and the gameobject is set to the root bone of a model.

Would anyone know why this does not work?

using UnityEngine;

namespace HutongGames.PlayMaker.Actions

    [Tooltip("Gets all rigidbodies on gameobject and its children recursively.")]
    public class GetAllRigidBodiesInChildren : FsmStateAction

        [Tooltip("The GameObject to get recursive children from.")]
        public FsmOwnerDefault gameObject;

        [Tooltip("if true, will list inactive gameobjects")]
        public FsmBool includeInactive;

        [Tooltip("The Array Variable.")]
        public FsmArray array;

        private GameObject _go;
        private Rigidbody[] _result;

        public override void Reset()
            gameObject = null;
            includeInactive = false;
            array = null;

        public override void OnEnter()

        void Find()

            _go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (_go == null)

            _result = _go.GetComponentsInChildren<Rigidbody>(includeInactive.Value);

            array.RawValue = _result;


  • Administrator
  • Hero Member
  • *****
  • Posts: 14316
  • Official Playmaker Support
    • View Profile
Re: Action to get all rigidbodies in children (not working)
« Reply #1 on: April 10, 2019, 11:55:13 PM »

 setting array is tricky, I think you need to call .SaveChanges() on your array

 if that doesn't work on it own, try to resize the array to the right value and set each indexes manually in a for loop.

 or try to set the.ObjectReferences property instead of .rawvalue

 let me know if you can't get it to work still...