Experimenting with hitTest function. It's a bit rough, I am still learning, but I thought it could be helpful. The idea is you have two objects with "bounding boxes" and this function tells which direction the object is being struck. Used in this example to push one box with the other.
ATM it only works on box-shaped bounding boxes but that would be easy to change. Let me know what you guys think and how to improve!
It also has a couple side features like the size of the boxes changes dynamically according to the gravity.z .. Just ignore those haha the really interesting part for game design is the hit test.
This is a circle-to-circle based hittest. Used a little nifty math to make it accurate.
Matthew_Murdoch187 last edited by
This works really nicely - thanks!
Thank you! Another example I have been playing with. In this one I modified the particles example because I wanted to test hitting a large array of objects. At about fifty it results in lag, probably because my coding is subpar..
Any advice or improvements is always welcome!
Very nice work!
I was thinking about a quad implementation but I didn't know exactly how to do something like that. You demonstrated that wonderfully and pretty much tripled the amount of particles the scene can handle. Good job :)
I'm also quite impressed with how you made the already truncated circle hittest even shorter!
Thank you for the contribution, that's pretty cool stuff and I will definitely learn from this.
thanks dlivingstone! - very devious ways of speeding up the collision checks! :)
sea56 last edited by
I see that, although you limit the number of checks cleverly, you still have to check the distance for some, and you use "if((dxdx)+(dydy)<radii*radii)"
I notice there is a command in the documentation-
#Return the cartesian distance to a different Point object.
And wondered if you could incorporate that instead? Or if you had tried and found it slower than your method
Sebastian last edited by
I've noticed that too, I even use it in my own codes, but it does use the square root function which I believe can make it a bit slower.