Forum Discussion

Madeline-M's avatar
Madeline-M
Community Member
2 years ago

How to check if objects are intersecting multiple times

Hello, I'm wondering if someone may be to help with an interactive resource I'm building (please find attached).
 
The user moves the two sliders (one for left/right, one for up/down) and this moves the pale blue grid into view. The aim is for the user to move the grid so that Hotspot 1 intersects with the Oval 3 (blue circle). They press the 'Check' button to see if they have moved the grid to the correct place, and either 'Correct!' or 'Incorrect!' will appear.
 
For the intersection, I'm imagining my triggers will do something like the following:
 
Show layer 'Correct!'
When the user clicks the  'Check' button
If Hotspot 1 intersects with Oval 3 (blue circle)
 
 
Show layer 'Incorrect!'
When the user clicks the 'Check' button
If Hotspot 1 does not intersect with Oval 3 (blue circle)
 
 
The issue I have at the moment is that once Hotspot 1 and Oval 3 stop intersecting, variable 'hotspotFound' becomes False and doesn't become True again even if they intersect again.
 
If the Check button has never been used, how can I make 'hotspotFound' become True if they intersect for a second time?
 
Thanks
  • You've done some good work here, and are so very close to the answer. In fact, your second slide is on the right track. What you are looking for is the values of the sliders; the "intersect"s is distracting you.

    You already know the value the sliders have to have to  be in the correct spot, so you don't need the additional work of adding a hotspot and all its triggers. Simply stay with  and "Adjust variable hotspotFound set true when slider1 moves if slider1 is between 4 and 6 AND slider2 is between 4 and 6 else set variable hotspotFound to false" and "Adjust variable hotspotFound set true when slider2 moves if slider2 is between 4 and 6 AND slider1 is between 4 and 6 else set variable hotspotFound to false"

    Of course, you would need to leave slider1 and 2 at their natural values and not reset them.

    By the way, you only need two variables for the sliders, the one that changes when it moves (current), and one to hold the old value. When it moves, compare the current to the old to see which direction to move, and then set the old to the current.

  • Madeline-M's avatar
    Madeline-M
    Community Member

    Thanks Walt, really helpful! You're right, it's much easier using the slider values.

    Thanks also for looking at the slider variables, I've simplified it and am now only using two variables.