Pointentity Problem

Blitz3D Forums/Blitz3D Programming/Pointentity Problem

Here's an example using AlignToVector.

Global vx#, vy#, vz#

Global not_collided = True

Global timer = CreateTimer( 25 )

Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

Global cam = CreateCamera()
CameraZoom cam, 1.6
MoveEntity cam, 2.0, 2.0, -10.0

Global light = CreateLight()

Global cone = CreateCone()
RotateMesh cone, 90.0, 0.0, 0.0
UpdateNormals cone

Global cube = CreateCube()
UpdateNormals cube
PositionEntity cube, 20.0, 10.0, 40.0

While Not KeyHit( 1 )

	If EntityDistance( cube, cone ) < 1.0
	
		HideEntity cone
		EntityColor cube, 255.0, 0.0, 0.0
		not_collided = False
		
	EndIf
	
	If not_collided
	
		MoveEntity cube, -0.22, 0.0, 0.0
		
		;PointEntity( cone, cube )
		vx# = EntityX( cube, True ) - EntityX( cone, True )
		vy# = EntityY( cube, True ) - EntityY( cone, True )
		vz# = EntityZ( cube, True ) - EntityZ( cone, True )
		AlignToVector( cone, vx#, vy#, vz#, 3, 0.15 )
		MoveEntity cone, 0.0, 0.0, 0.31
	
	EndIf
	
	UpdateWorld
	RenderWorld
	
	Flip
	
	WaitTimer( timer )

Wend

End