delaying proximity reaction makes sensor unresponsive for the time of delay
In a recent post I had a problem implementing a delay in the proximity manager and Jeff has suggested the solution of using "vizproximity.waitEnter" and a while loop:
Code:
def proximityTask(): What happens now is that, once the sensor is entered, the action (change of the variable handstate from 0 to 1), will be delayed by two seconds. However if I happen to enter the sensor again very quickly, before these two 2 seconds have elapsed, nothing happens, as it seems that it is not registered that the sensor has been entered, until the first action takes place. I wonder if there is a way around this? I tried to to the following: I will change a new variable upon entry but then I will make a new function where I say that IF the new variable "condition" is equal to 1 then after 2 seconds the handstate should change to 1 (= delayed action). This way I am hoping that I am not delaying the action itself in the proximity manager, I am delaying it outside of that function so that the proximity manager can freely register all entries. Code:
Code:
def Handdelay(): I would be very grateful for help! |
It sounds like you need to determine whether the sensor was exited before two seconds elapsed. If that's the case, use the viztask.waitAny command to help with this:
Code:
def proximityTask(): |
I have tried this code but what it does is, it triggers the action as long as the sensor is still entered, after 2 seconds and does not do that if the sensor is exited before 2 seconds have elapsed.
I actually think this might be a different issue: I want an action to be triggered with a delay, every single time a sensor is entered. If I use waitEnter and waitTime what I achieve is that I "block" the sensor - nothing is registered until the action (and the 2 second delay) are carried out. So it cannot be that I trigger the action EVERY time a sensor is entered, because the 2 second delay creates a minimum of time that needs to have passed before another sensor entry is even registered. Basically, I want the sensor to be entered instantly, each time, and only the action - which is a consequence of the sensor entry - should be triggered with a delay. Another illustration: 1) If I approach an object, I enter its sensor and I trigger an action of that object. 2) If I want a 2 second delay: I approach an object, I enter its sensor and I trigger an action of that object only after 2 seconds. 3) The problem comes now: If I approach an object a second time within one second of the first time, nothing will happen, because the program is still carrying out the action with delay scheduled as a response to the first approach. |
Try the following example. After the sensor enter event occurs in the proximity task another task is called that handles the delay:
Code:
import viz |
Jeff, thank you very much! It works perfectly, I have adapted it for my script:
Code:
def delayTask(): |
All times are GMT -7. The time now is 04:09 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC