Attaching collision to mesh

Blitz3D Forums/Blitz3D Beginners Area/Attaching collision to mesh

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hey Sec05, are you still stuggling with this one?

First up, do you fully understand what the help files means when it say 'Collisions are always Elipsoid to something'?

In practical terms, it means you character mesh won't have exact collision detection, instead it will be bounded by an elipse, and you'll check if that collided.

So the basics would be:

;first, set up names for the collision types

const TYPE_CHARACTER=1
const TYPE_LEVEL=2

;then tell Blitz what form of collision will occur. 
;The first "2" tells it to check for elipsoid-to-polygon 
;collision. This means your level can be any shape you want,
;but your character's collision will just be approximated to
;a circle. The second "2" indicates full-sliding collision - ;the most common type.

Collisions TYPE_CHARACTER,TYPE_LEVEL,2,2

;Now loading the character

char=loadmesh("char.3ds)
entitytype char,TYPE_CHARACTER
entityradius char,3 ;I'm just guessing here, giving it a circle of radius 3 around it for collisions

;now loading the level
level=loadmesh("level.3ds)
entitytype level,TYPE_LEVEL
;now you DON'T need to set up the levels entity radius, 
; as it doesnt' move, and were checking the POLYGONS in 
;the level mesh (it's 'elipsoid to POLYGON collisions we ;chose, remember?)

;put all the rest of the code here

;inside the main loop
renderworld ;this tells blitz to check for collisions
updateworld 


now, if you have two moving entites (such as an enemy and a player character) you'll need to do collision on both of them, both of the ways around. I.e you'll need

const TYPE_CHARACTER=1
const TYPE_ENEMY=3

Collisions TYPE_CHARACTER,TYPE_ENEMY,2,2
Collisions TYPE_ENEMY,TYPE_CHARACTER,2,2

;also define entity radius for both of them
char=loadmesh("char.3ds)
entitytype char,TYPE_CHARACTER
entityradius char,3 ;just a guess, tweak in game

enemy=loadmesh("enemy.3ds)
entitytype enemy,TYPE_ENEMY
entityradius enemy,3 ;again, just a guess


But since the level mesh doesn't move (does it?) you don't need to do two-way collision checking between character and level.

Hope this helps