Character Movement

Blitz3D Forums/Blitz3D Beginners Area/Character Movement

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here's a little code that includes a smooth cam. It's not really much. You kinda have to build you own way sort of. But the camera movement is important. You don't really want it to be too rigid, as it might make your controls seems worse i feel.

Graphics3D 800,600
SetBuffer BackBuffer()


Global cam = CreateCamera()

Global light = CreateLight()

Global player = CreateCone()

Global cam_pivot = CreatePivot(player)
PositionEntity cam_pivot,0,1,-5

Global ground = CreatePlane()
PositionEntity ground,0,-1,0

; CREATE A PLANE AND A TEXTURE

Global g_tex = CreateTexture(64,64)

SetBuffer TextureBuffer(g_tex)
For loop = 0 To 100
	Color Rand(10,255),Rand(10,255),Rand(10,255)
	Rect Rand(0,60),Rand(0,60),Rand(1,3),Rand(1,3)
Next

EntityTexture ground,g_tex

; ____--_____________________

While Not KeyHit(1)



	If KeyDown(203) Then TurnEntity player,0,1,0
	If KeyDown(205) Then TurnEntity player,0,-1,0
	If KeyDown(200) Then MoveEntity player,0,0,0.1
	If KeyDown(208) Then MoveEntity player,0,0,-0.1
	
	update_cam(100) ; lower the number in the brackets for quicker cam movement
	UpdateWorld
	RenderWorld
	Flip
Wend
End

Function update_cam(speed#)

	PointEntity cam,cam_pivot
	MoveEntity cam,0,0,EntityDistance#(cam,cam_pivot)/speed
	PointEntity cam,player
	
End Function


EDIT >> Probably not half as good as Joe's link <<