collision

Blitz3D Forums/Blitz3D Beginners Area/collision

Link(Posted 2008) [#1]
can anyone tell me, in simplest terms, how to make collision detection? thats all i wanna know.


Amanda Dearheart(Posted 2008) [#2]
Blitzd contains commands to detect Collision detection.
They are Collisions
and Entity Collisions.

In the Manuals tab on this website look under the Globals section of the 3d category section.
They have examples for their usage.


Warner(Posted 2008) [#3]
For your main character entity, use
EntityType char, 1
EntityRadius char, 1

For your world mesh, use
EntityType world, 2

Then, enable collisions with
Collisions 1, 2, 2, 4

And in your main loop, use
UpdateWorld
RenderWorld

Blitz3d collisions are allways sphere-to-something, so that is why you must set the radius for your character mesh.


MyNickNameWasTaken(Posted 2008) [#4]
Does anyone know of a way to check for collisions without triggering one of the automatic responses: Stop, slide1, or slide2.

For example, say I've attached/parented a Pivot to a animating boxer's hand bone. That way the Pivot moves where ever the boxer puts his hand. I want to be alerted anytime that Pivot collides with a punchable object. Collision will do that, but every time the Pivot hits something, it stops or slides, thus moving it off of the boxer's hand bone. I can repossession the Pivot after each collision, but that seems like a poor solution to the problem.


Link(Posted 2008) [#5]
i just tried it, but the example doesnt work. this is what im talking about!!!!
can anyone make an example where i can just plug the entities in to run it?


MyNickNameWasTaken(Posted 2008) [#6]
Do you mean it doesn't work as in it doesn't run, or it doesn't work as in you can't change the collision type with the R and M keys?


Link(Posted 2008) [#7]
ill just put the code and let you decide lol

Graphics3D 0,0,0,1
SetBuffer BackBuffer()
CT = LoadMesh ("collisiontest.3ds")
PositionEntity CT,20,10,2
EntityType CT,2
EntityRadius ct,5

camera=CreateCamera()
EntityRadius camera,5
PositionEntity camera,1,1,1
EntityType camera,1
light=CreateLight()


; Set terrain detail, enable vertex morphing
TerrainDetail terrain,4000,True

; Scale terrain
ScaleEntity terrain,1,50,1

; Texture terrain
ScaleEntity terrain,1,50,1
PositionEntity terrain,0,0,5

grass_tex=LoadTexture( "texture1.bmp" )
EntityTexture terrain,grass_tex,0,1
ScaleTexture grass_tex,75,75
EntityTexture terrain,grass_tex,0,1

While Not KeyDown( 1 )

If KeyDown( 203 )=True Then x#=x#-0.1
If KeyDown( 205 )=True Then x#=x#+0.1
If KeyDown( 208 )=True Then y#=y#-0.1
If KeyDown( 200 )=True Then y#=y#+0.7
If KeyDown( 44 )=True Then z#=z#-0.1
If KeyDown( 30 )=True Then z#=z#+0.1

If KeyDown( 205 )=True Then TurnEntity camera,0,-1,0
If KeyDown( 203 )=True Then TurnEntity camera,0,1,0
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-0.1
If KeyDown( 200 )=True Then MoveEntity camera,0,0,0.7

x#=EntityX(camera)
y#=EntityY(camera)
z#=EntityZ(camera)

terra_y#=TerrainY(terrain,x#,y#,z#)+10

PositionEntity camera,x#,terra_y#,z#
UpdateWorld
RenderWorld

Collisions camera, ct, 1, 2

Collisions CT, camera, 1, 2
Flip

Wend

End


MyNickNameWasTaken(Posted 2008) [#8]
I see one problem off the bat.

Collisions camera, ct, 1, 2

Collisions CT, camera, 1, 2

This should be

Collisions 1, 2, 1, 2

Collisions 2, 1, 1, 2

Your supposed to use entity_types (numbers) rather than actual entities in collisions.


Link(Posted 2008) [#9]
YESSSSSSS!!!! YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESSSSSS!!! That's IT!!!!
you dont know HOW LONG ive been trying to find that out! a year at least!!!! if you go on search my subjects on this are on there a ton! but THANK you! you dont know how much i needed this! thx again! bye


MyNickNameWasTaken(Posted 2008) [#10]
:D Being helpful is fun.


Zethrax(Posted 2008) [#11]
I'd suggest looking at the 3d samples that come with Blitz3D to see collision code in action. Bear in mind that collisions don't work against non sphere/ellipsoid collision target objects that are moving towards the source object (which must be a sphere/ellipsoid).

Also, I've never gotten much sense out of ellipsoidal collisions. It seems like the aspect ratio needs to be the same for all the collision ellipsoids used, which makes them fairly useless.

Collisions only have stop and slide response types available. For a no-respose type you will need to use a collision proxy. Try the link below for example code.

http://www.blitzbasic.com/codearcs/codearcs.php?code=1901