hovering a ship

Blitz3D Forums/Blitz3D Beginners Area/hovering a ship

Hey, i've knocked this together. Shows a basic example of what your wanting. Re-reading my post, you should add the height above the track you want the ship to be, to the pickedy(), to get the Y co-ord you want your ship to be at.

Graphics3D 800,600
SetBuffer BackBuffer()


Global cam = CreateCamera()

Global light = CreateLight()

Global ship = CreateCube()

Dim track(9); create a dummy track out of spheres
For loop = 0 To 9
	track(loop) = CreateSphere()
	ScaleEntity track(loop),3.5,4,10
	PositionEntity track(loop),-20+loop*5,0,0
	EntityPickMode track(loop),2
Next

PositionEntity cam,0,0,-20
PositionEntity ship,0,5,0

Global dist_above_track# = 3


While Not KeyHit(1)


	If KeyDown(203) Then MoveEntity ship,-0.1,0,0
	If KeyDown(205) Then MoveEntity ship,0.1,0,0


	x# = EntityX(ship,True)
	y# = EntityY(ship,True)
	z# = EntityZ(ship,True)
	
	LinePick x,y,z,0,-10,0 ; perform the line pick
	
	If PickedEntity() <> 0 Then ; make sure an entity has been picked
		PositionEntity ship,x,PickedY()+ dist_above_track,z ; place the ship above the pickedy() co-ord
	End If



	UpdateWorld
	RenderWorld
	Text 0,0,(PickedY()+ dist_above_track)
	Flip
Wend
End