Can someone give me an example of how the hitTest options work? I checked the reference on it but I still don’t understand…
to be honest, i’m just as confused with the example as you are. (if you’re talking about the new 1.19 hits options.) i think jovanny put it best at some point, it’s good to look at but it’s not a great way to teach us how it works.
Idk a lot about the new hits code, but here’s what I know:
You can change the hits mode like this:
hitTestOptions({mode: 'CONVEX'});
You can set the mode to either CONVEX, CIRCLE, or RECTANGLE, which changes the hitbox of the clip. Convex is the most accurate hitbox.
Changing the mode affects the hits function results.
There’s other things you can set, like:
hitTestOptions({offset: true}) /* return true if offset */
hitTestOptions({overlap: true}) /* return true if objects overlap */
hitTestOptions({intersections: true}) /* return true if objects intersect */
Or you can set everything at once, like this:
hitTestOptions({
mode: 'CONVEX';
offset: true;
overlap: true;
intersections: true;
});
I recommend setting the hits function in the default script.
However you set it effects how the hits function works throughout the project.
I still don’t know if this is how it works, because (like I said) idk a lot about the new hits code
oh ok that makes sense. Thx!
This saved my project today… for some reason, the hits functionality was throwing exceptions in my project related to the hitTestOptions to not be set. I just put this at the begining of the default script, at the first frame and it is working great. Thank you!
hitTestOptions({
mode: 'RECTANGLE',
offset: true,
overlap: true,
intersections: true
});