TForm

Blitz3D Forums/Blitz3D Programming/TForm

Here's a way to do it using the AlignToVector command.

In this code the cone is being aligned on its Y axis to point at the sphere. Assuming your quad is pointing along its positive local Z axis then you'd use a 3 at the end of the AlignToVector command instead of a 2.

You can also add a tween value from 0.0 to 1.0 at the end of the AlignToVector command to smooth out the rate of alignment. Check out the AlignToVector command docs for more info on this.



Graphics3D 800,600

light = CreateLight ()
TurnEntity light, 45.0, 0.0, 0.0, True

camera = CreateCamera ()
CameraZoom camera, 1.6
TurnEntity camera, -90.0, 0.0, 0.0, True
MoveEntity camera, 0.0, 0.0, -30.0

cone = CreateCone ( 8, True )
MoveEntity cone, 0.0, 0.0, 5.0

sphere = CreateSphere ( 16 )
;MoveEntity sphere, 0.0, 0.0, -2.5


While Not KeyHit ( 1 )

	; -- Move the cone by pressing the arrow keys.
	If KeyDown( 200 ) ; The up arrow key.
		MoveEntity cone, 0.0, 0.0, 0.2
	EndIf

	If KeyDown( 208 ) ; The down arrow key.
		MoveEntity cone, 0.0, 0.0, -0.2
	EndIf

	If KeyDown( 205 ) ; The right arrow key.
		MoveEntity cone, 0.2, 0.0, 0.0
	EndIf

	If KeyDown( 203 ) ; The left arrow key.
		MoveEntity cone, -0.2, 0.0, 0.0
	EndIf
	;^^^^^^

	; -- Align the y axis of the cone to point towards the sphere.
	AlignToVector cone, EntityX# ( sphere, True ) - EntityX# ( cone, True ), EntityY# ( sphere, True ) - EntityY# ( cone, True ), EntityZ# ( sphere, True ) - EntityZ# ( cone, True ), 2 ; Use a 3 at the end here to align the z axis instead.
	;^^^^^^

	UpdateWorld
	RenderWorld
	Flip

Wend

End