void Reset()
        {
            g_Controller = GetComponent <NPCController>();
            g_Controller.Debug("Initializing NPCPerception...");
            // add perception fields
            g_Controller = gameObject.GetComponent <NPCController>();
            GameObject pf;
            Component  sCol = g_Controller.GetComponent(PERCEPTION_FIELD_OBJECT);

            if (sCol == null)
            {
                // take into account not reading a duplicate Sphere Collider in the same layer
                pf = new GameObject();
            }
            else
            {
                pf = sCol.gameObject;
            }
            pf.name             = PERCEPTION_FIELD_OBJECT;
            pf.layer            = LayerMask.NameToLayer(PERCEPTION_LAYER);
            pf.transform.parent = g_Controller.transform;
            // reset transform
            pf.transform.rotation      = g_Controller.transform.rotation;
            pf.transform.localPosition = Vector3.zero;
            pf.transform.localScale    = Vector3.one;
            gPerceptionField           = pf.AddComponent <SphereCollider>();
            gPerceptionField.isTrigger = true;
            gPerceptionField.radius    = (MIN_PERCEPTION_FIELD + MAX_PERCEPTION_FIELD) / 4;
            gViewAngle = (MIN_VIEW_ANGLE + MAX_VIEW_ANGLE) / 2;
            // collisions / reach
        }
 public BEHAVIOR_STATUS Behavior_DoGesture(GESTURE_CODE Gesture, System.Object Value = null, bool Timed = false)
 {
     if (gNPCController.Body.IsTimedGesturePlaying(Gesture))
     {
         return(BEHAVIOR_STATUS.RUNNING);
     }
     else if (g_GestureRunning)
     {
         g_GestureRunning = false;
         return(BEHAVIOR_STATUS.SUCCESS);
     }
     else
     {
         try {
             gNPCController.Body.DoGesture(Gesture, Value, Timed);
             g_GestureRunning = true;
             return(BEHAVIOR_STATUS.RUNNING);
         } catch (System.Exception e) {
             gNPCController.Debug("Could not initialize gesture with error: " + e.Message);
             return(BEHAVIOR_STATUS.FAILURE);
         }
     }
 }
        // Use this for initialization
        void Start()
        {
            g_NPCController = GetComponent <NPCController>();
            g_NPCBody       = g_NPCController.Body;
            g_Animator      = GetComponent <Animator>();


            if (g_Animator == null)
            {
                g_NPCController.Debug("NPCIKController --> An animator controller is needed for IK, disabling component during runtime");
                this.enabled = false;
            }

            // default weight
            IK_WEIGHT = IK_WEIGHT < 0.1f ? 1f : IK_WEIGHT;

            g_RightFootPosition = RIGHT_FOOT.position;
            g_LeftFootPosition  = LEFT_FOOT.position;
        }