How to Suspend Sensors for 20 Frames ?

Hello and Happy New Years Everyone,

I have defined a Global Boolean, which is set to true once collision in script A occurs. I would like to suspend the sensory input for 20 frames once the Global Boolean is set to true in Script B. So I check whether the Global Boolean is true in Void Update in Script B, but I am a bit puzzled on how I can suspend the sensors for 20 frames. Any suggestion ?

public override void CollectObservations(VectorSensor sensor)
    {
        sensor.AddObservation(pendulumA.transform.localPosition); // joint coordinates (vec. 3)
        sensor.AddObservation(pendulumA.transform.rotation); // rotation of joint (quat. 4)
        sensor.AddObservation(m_RbA.angularVelocity); // (vec 3)
        sensor.AddObservation(m_RbA.velocity); // (vec 3)

        sensor.AddObservation(pendulumB.transform.localPosition); // joint coordinates (vec 3)
        sensor.AddObservation(pendulumB.transform.rotation); // rotation of joint (quat. 4)
        sensor.AddObservation(m_RbB.angularVelocity); // (vec 3)
        sensor.AddObservation(m_RbB.velocity); // (vec 3)

        //sensor.AddObservation(goal.transform.localPosition); // goal coordnates (vec 3)
        // Debug.Log(active.transform.parent);
        // Debug.Log(active.transform.parent.localPosition); // print out input vec of active target
        sensor.AddObservation(active.transform.parent.localPosition); // takes position of active target
        sensor.AddObservation(hand.transform.localPosition); // hand cooardiantes (vec 3)

        sensor.AddObservation(m_GoalSpeed); // (1)
        // total number of params. in input vector = 33
    }
void Update()
    {
      if (Global_Var.boolean == true)
             {
               Suspend Sensors
              }
    }

Don’t check the global boolean state every frame. Have script A tell script B that it’s time to suspend. That can be a boolean in script B, no need for it to be global.

1 Like

So I can define a local bool variable in Script A and check whether it is true in Script B ? Something like this ?
In Script B:

if (ScriptA.localbool == True)
{
DO SMT
}

Script A just senses the collision, then runs a function in script B that will initiate the suspension (suspend, start counting, count to 20 frames and stop suspending). If you’re counting frames, you’d need the bool, so Update() will call the counting function. If you want to suspend for a certain amount of time, use Invoke(), and there’s no need for the bool at all.

1 Like

Check into how to access the script itself. Wouldn’t be Game_Manager, it’s the name of the script. Look into how to communicate between two scripts.