Tank Controls

Blitz3D Forums/Blitz3D Beginners Area/Tank Controls

Maybe you could avoid parenting the turret at the hull, and use PositionEntity turret, EntityX(hull), EntityY(hull), EntityZ(hull) instead ? Or use something like this ?

	Graphics3D 800, 600, 0, 2
	SetBuffer BackBuffer()
	
	;create pickable floor, for positioning aim
	plane = CreatePlane()
	EntityPickMode plane, 2
	EntityColor plane, 0, 255, 0
	
	;create camera
	cam = CreateCamera()
	PositionEntity cam, 0, 15, 0
	RotateEntity cam, 90, 0, 0
	
	;create hull
	hull = CreateCube()
	ScaleEntity hull, 1, 0.2, 1
	EntityColor hull, 255, 0, 0
	
	;create turret
	tur = CreateCylinder(4, 1, hull)
	ScaleMesh tur, 0.1, 2, 0.1
	RotateMesh tur, 90, 0, 0
	PositionMesh tur, 0, 1, 2
	EntityColor tur, 0, 0, 255
	
	;create 'aim' object
	aim = CreateSphere()
	ScaleMesh aim, 0.1, 0.1, 0.1
	
	Repeat
	
		If KeyDown(203) Then TurnEntity hull, 0, +2, 0
		If KeyDown(205) Then TurnEntity hull, 0, -2, 0
		If KeyDown(200) Then MoveEntity hull, 0, 0, 0.1
		If KeyDown(208) Then MoveEntity hull, 0, 0, -0.1
	
		;position 'aim'	object
		CameraPick cam, MouseX(), MouseY()
		PositionEntity aim, PickedX(), PickedY(), PickedZ()
		
		;point turret at 'aim'
		PointEntity tur, aim
		
		RenderWorld()
		Flip
		
	Until KeyHit(1)
	
	End