Physics+Hit Detection


(Lucky) #1

Hey,

Made a posting about this on the other forum.
http://hype.desk.com/customer/portal/questions/12796834-controlling-gravity-in-js-hit-test-detection
And went trough the example files which definetly cleared up some things, but with the big issue of hit detection I’m still confused on alternatives.

If you were to let something interact with something else with hype physics is there an easy way to hitTest it without using jQuery/JS? If not what’s a good way to do it the JS way?

The example thread posted had the user using “MutationObserver” which seems like a less than ideal way to do things. Has anyone else tried Hit Tests with physics?

Thanks


(strmiska) #2

you can check this:
egg.hype.zip (117.8 KB)

drag the left dog to the right one and its shell will burst (disappear) on collision.


(Hans-Gerd Claßen) #3

at this point nothing has changed since that thread.

matter.js as underlying js-library doesn’t support collisiondetection (as far as i heard) …
so, you’ll need your own event to catch elements attributes changing. the only one i know is the mutation-event.

if you need collision-detection on drag-event you can use jqueries or hypes events


(Lucky) #4

Thanks for the suggestions, yeah it still seems kind of hacky and yeah those ways wil lwork as a temp fix. Appreciate the help!