Blitz3D collision tips

Blitz3D Forums/Blitz3D Tutorials/Blitz3D collision tips

Uhfgood(Posted 2005) [#1]
I've created this as a place to host tips on blitz3d collisions - so I can remember them and so other newbies can learn blitz3d collisions instead of blindly just "trying stuff till stuff works".

Admittadly I too am a newb when it comes to blitz3d - But what i've learned in the past couple of days thanks to the kindness of some other blitz3d coders, is invaluable.

So here i've decided to put the few things I learned...
I may be the only one that posts to this message, and I only have a couple of things to start off with anyways. Please only put blitz3d related collision stuff in this thread, as i'm not interested in third party libraries where there's bound to be plenty of forums and messages dedicated to them.

Okay here are the 2-3 tips I learned -

First collision checking may occur when even initial positioning of an object, ie. PositionEntity is affected by collisions, so you must either assign an entity type afterwards, or call ResetEntity after positioning.

Secondly I was told by someone that EntityBox uses coordinates that start with the upperleft corner that faces you (the camera initialy) instead of the middle of the entity as in other functions. They also said it wasn't mentioned in the docs...

Thirdly is just more common sense than anything else, and most everyone else may not have this problem, I couldn't move my object over another that it collided with because I forgot to reset my "y" velocity... so it kept increasing the velocity each time bigger in bigger not allowing me to move... So just remember when implementing gravity say like in a platform game, to reset your y velocity when you've hit the platform.

That's all, nothing earth shattering, and in fact most people would wonder why I would post this at all. Mostly I wanted a place that I could add my own stuff, a place to keep it centralized, also so newbies could learn from my mistakes.

Other few things of note :
sphere-to-polygon collision is easier to use - but if your program has too many poly's or objects then it's slower than sphere-to-box...
You only need to call Collisions once at initialization unless you plan to call ClearCollisions in code for some reason.
You don't need to set multiple entitytypes for every single entity, you DO have to call EntityType for each entity but you can group any or all of your entities into one type - For instance my game has an array of cubes setup as a table each cube is set to a single entity type... And I merely call collisions once with it.

Umm that's all I can think of. Any of you veterans can correct me if i'm wrong, and also add your own tips.

Thanks


Matty(Posted 2005) [#2]
For performance tips regarding collisions:

Usually you will want ellipsoid to polygon collisions set up between your 'characters' and your level. Rather than use the level itself as the collision mesh, make a low polygon mesh which can be used as the collision mesh with entityalpha set to zero so that the collision mesh is not rendered but allows for quick collision detection.


Ross C(Posted 2005) [#3]
If your doing sphere to sphere collisions, and don't need a collision response, use EntityDistance() instead :o)


Talavar(Posted 2014) [#4]
Collisions gave me quite a problem.. Mainly because of a failure in the older documentation. Im actually using an older version of blitz because the new version is failing left and right for me.
. If you can't get your collisions to work, remember that you have to declare that your collisions can happen
so if you have entitytype cube,1
and you have entitytype sphere,2
if they collide and nothing happens.. remember that you have to tell the program to turn on collisions between these two types.
so Collisions 1,2,2,2
the first two numbers are the types. The other numbers are the collision type that it checks for and how they react.