Attaching collision to mesh

Blitz3D Forums/Blitz3D Beginners Area/Attaching collision to mesh

sec05(Posted 2004) [#1]
Want to ask something here.

I have done a character in 3ds max and was wondering how do I make collision detection to this character? I have also created a wall in 3ds max and I wanted to stop the character from going through the wall when I control him.

I know about the collision command in blitz, but it is not working at all. And from what I see from the examples on the tutorials, only objects that are created DIRECTLY from blitz(ex. using the CreateCube() command) are working.

So does that mean that in order for my character to have collision detection, I have to create a cube or a sphere in blitz, position it as the same position as the character, make it invisible, and attach it to the character using the EntityParent command so as to make the collision work? If that is the case, won't it be very tedious if I have alot of objects in my game?

Thanks for the time!


Hujiklo(Posted 2004) [#2]
First read up on 'entitytype' command. This will help make sense of what blitz does with collisions.


joerae(Posted 2004) [#3]
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