Collision

Blitz3D Forums/Blitz3D Programming/Collision

I want to detect collision but not allow blitz to stop the movement of my objects.
Example:
Soldier hits enemy soldier with a sword. The sword doesn't stop when it hits... it cuts right into the flesh.

MeshesIntersect (mesh_a,mesh_b ) should do... Hopefully is not too slow.

MeshesIntersect is slow.

Use a proxy object (sphere) parented to the sword, and perform collision detections on that instead.

^^ [edit]what he said.[/edit]

Wouldn't the sphere object, once collided, stop the sword from moving? It is colliding after all...

It would be the other way around, the sword would stop the sphere object from moving. To avoid a complete stop, force the sphere to keep moving:
; CreateCone Example
; ------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()

light=CreateLight()
RotateEntity light,90,0,0

; Create cone
cone=CreateCone(25,1)
;create cube
cube=CreateCube()
MoveEntity cube, 0,0,5
;create sphere for collisions
coll_sphere=CreateSphere()
ScaleEntity coll_sphere,0.5,0.5,0.5
EntityRadius coll_sphere,0.5
EntityAlpha coll_sphere, 0.5

;set collision types
EntityType cube, 2
EntityType coll_sphere, 1
Collisions 1,2,2,1

;main loop
While Not KeyDown( 1 )

	;calc. y position
	tim=tim+1
	ypos#=Cos(tim)*3
	;move cone
	PositionEntity cone,0,ypos,5
	;reset collision sphere
	PositionEntity coll_sphere,0,0,0
	ResetEntity coll_sphere
	;move collision sphere where the cone is
	PositionEntity coll_sphere,0,ypos,5
	
	;update&render
	UpdateWorld()
	RenderWorld
	
	;check collision
	If EntityCollided(coll_sphere, 2) Then Text 0, 0, "collided!"
	
	Flip

Wend

End

For a sword, maybe a cube (entitybox) is more suitable. Or a Pivot at the top of the sword.