I’ve been banging my head against a wall with this one. I have a physics block as sensor, and I want to trigger a function if an object comes in contact with the sensor for more than 3 seconds, but if the object stops touching the sensor within those 3 seconds, nothing would happen. I’ve tried several ways to do this, but nothing worked in the end. Any suggestions? Thanks in advance. Cheers! [import]uid: 66329 topic_id: 34049 reply_id: 334049[/import]
Hey, I’d try having the collision trigger a timer that calls a function after 3 seconds. In that function, test if your object is within a certain x / y range of your sensor block.
I’ve had trouble getting sensor objects to detect a second collision. Testing the x /y coords might be your best bet.
Hope that helps. [import]uid: 136211 topic_id: 34049 reply_id: 135395[/import]
Hello,
I would suggest you associate a timer with the sensor, and when the object enters it (began phase) you begin the timer. If the timer completes, boom, do whatever. If the object exits the sensor before then (ended phase), you cancel the timer.
This could get more complicated if you need to keep track of several objects that might be entering and exiting the sensor region. Then you’d need to ensure that multiple timers weren’t started, and keep count of how many objects were within the region, etc.
Hope this helps,
Brent [import]uid: 200026 topic_id: 34049 reply_id: 135397[/import]
Hey, I’d try having the collision trigger a timer that calls a function after 3 seconds. In that function, test if your object is within a certain x / y range of your sensor block.
I’ve had trouble getting sensor objects to detect a second collision. Testing the x /y coords might be your best bet.
Hope that helps. [import]uid: 136211 topic_id: 34049 reply_id: 135395[/import]
Hello,
I would suggest you associate a timer with the sensor, and when the object enters it (began phase) you begin the timer. If the timer completes, boom, do whatever. If the object exits the sensor before then (ended phase), you cancel the timer.
This could get more complicated if you need to keep track of several objects that might be entering and exiting the sensor region. Then you’d need to ensure that multiple timers weren’t started, and keep count of how many objects were within the region, etc.
Hope this helps,
Brent [import]uid: 200026 topic_id: 34049 reply_id: 135397[/import]