Python script to control raycast sensor sampling time

Hi

I am trying to make a Python script for controlling the sampling time of my raycast sensors. I have several sensors and it would be easier to adjust the desired sampling via a script. I connected all of the sensors and the script to the sample variable, turned off all of the UseSampling checkboxes.

This is my script:
<h6>##################</h6>
from vcScript import *

def OnRun():
comp = getComponent()
app=getApplication()
sampletime=comp.findBehaviour(“boolSampletime”)

while app.Simulation.IsRunning == True:
sampletime.signal(True)
delay(0.1)
sampletime.signal(False)
delay(0.1)
<h6>##################</h6>
During runtime my sample variable is turning on and off with the good frequency and my raycast sensors can detect one part. After turning to True state the connected variables would not turn back to False state when the part passed the sensor. Does anyone know how to fix this problem, or have a solution to sampling time adjustments? Thanks for the help in advance!

Hello

Could You provide a component / example where You try to use this approach. From the example we could see what You area trying to achieve.

E.g. RayCastSensor behaviour has SampleTime property that You can adjust. You can access all sensors via script (allsensors = comp.findBehavioursByType(VC_RAYCASTSENSOR) and then change the SampleTime property to them all when needed.