making a 'smart' camera

Blitz3D Forums/Blitz3D Programming/making a 'smart' camera

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 one I made, works really nice, and very simple..
if you want, you can use sliding collision for the camera to keep it from going through walls if you want.

it's a lot like DB's "Set camera to follow command"
the 'point' flag at the end will also point 'e1' at 'e2' if set to 1

Function Curve#(d#,c#,s#)
	If Abs(d-c)<0.01
		Return d
	Else
		Return c+((d-c)/s)
	EndIf
End Function

Function followEntity(e1,e2,angle#,dist#,height#,speed#,point=0)
	x# = EntityX#(e2)+(Sin(angle#)*dist#): y# = EntityY#(e2)+height#: z# = EntityZ#(e2) - (Cos(angle#)*dist#)
	PositionEntity e1,curve#(x#,EntityX#(e1),speed#),curve#(y#,EntityY#(e1),speed#),curve#(z#,EntityZ#(e1),speed#)
	If point Then PointEntity e1,e2
End Function


Use:
followEntity(camera,player,entityyaw#(player),100,200,10,1)