Collision testing
Blitz3D Forums/Blitz3D Programming/Collision testing
| ||
Is there a way to test for a collision without that entity being affected by a collision? For example, a cube that is positioned at the player's feet each loop: can I test if it is touching the ground without it being stopped from going through the ground (so it will stay the the player's feet no matter what) ? |
| ||
The only way you can do it, is with a proxy object. Create an object (cube or sphere, doesn't much matter) with your player model as its parent. Set its alpha to 0, then perform collisions on that rather than the player. You may need to reposition the proxy object each frame by hiding it, repositioning, then showing (hiding disables collisions). |
| ||
Ok. I thought there might be an automated way to do it. Thanks. |
| ||
You can't have a cube as a source collision object, Mattizzle, only ellipsoids. Below is a link to a some code I posted for doing something similar to what GFK suggested. http://www.blitzbasic.com/codearcs/codearcs.php?code=1901 |
| ||
Wow! Nice code! Thanks for sharing! |
| ||
I had a problem with my jump code a while back and decided to use a proxy object to test collisions. Instead of parenting it to the player, I position it to the players coords -wherever each frame. Remember if you "HIDE" and object then move it back to where you want it, then "SHOW" it, during those steps it is not affected by collisions. As far as "triggers" you can have a timer. If you hit a trigger then hide it, until its "respawn time" is at a certain value, then place it back on the field again with an alpha of 0. If you use velocities and inertia to move objects, you dont notice the single frame that you slam into these invisible objects. However, I do believe the count collisions command is pretty slow. Numbers are always the best solution. |