I’m currently prototyping a fruit-slicer-like game.
I’m only planning to integrate a simple hit / no-hit mechanic (no direction of cut / custom cut).
What would be a simple strategy to detect this “swipe over / through” on 3d-Objects ?
I can remember an old babylon.js example, where an actual line was created and then checked for collision, but maybe there is a simpler way.
So, if you don’t want to go all the way creating custom line meshes you can use a raycast.
If the game is taking place on the XY plane, then convert your touch input in world points at the same Z distance from the camera as the fruit objects and do a raycast from start to end, or for better accuracy multiple ones that follow the touch gesture.
You can check that way if there was a hit with an object.
Thanks Leonidas, that makes sense.
Just out of curiosity - If I would create a custom line mesh, how would I then detect the collision, some Frame Buffer Magic?
So if you’ve built a custom mesh, each line segment could be potentially a separate mesh instance and instead of raycasts, you could use the bounding box for checking intersections.
I am not saying that’s better, I think I would still use raycasts in that case as well.
Thanks guys.
The 2d version also makes a lot of sense (reminds me of my old flash-stuff).
I will check If I need Ammo for the basic-gameplay, and then will see which of your workflows works best for me. Thanks again for your time!