EntityParent

Blitz3D Forums/Blitz3D Beginners Area/EntityParent

Jerome Squalor(Posted 2007) [#1]
Whenever I assign the Camera to ant entity as a parent everything looks so stiff.

Is there a way to make it so that when the child entity is turning, it turns a few degrees and then the camera starts turning with it?

Please post code

Thanks in advance


Mortiis(Posted 2007) [#2]
Here's a smooth 3rd person camera system I used some time ago...

Type SysCam
	Field cx#,cy#,cz#, yaw#
	Field cam
End Type

Global Camera.Syscam

Function LoadCamera()
	DebugLog "Initializing Camera System"
	Camera.Syscam = New Syscam
	Camera\Cam = CreateCamera()
	CameraRange Camera\Cam, 1, 9000
	CameraZoom Camera\Cam, 1
	CameraClsMode Camera\Cam, 0, 1
End Function

Function UnloadCamera()
	For Camera.Syscam = Each Syscam
		FreeEntity Camera\Cam
		Delete(Camera)
	Next
End Function
		
Function ChaseCam(entity, spd# = 0.1)
	TFormVector 0, 30.5 - (GraphicsHeight() / 2 - Camera\cy - MouseZ()) * 0.05, - 80 - MouseZ(), entity, 0
	ex# = EntityX(entity, True)
	ey# = EntityY(entity, True)
	ez# = EntityZ(entity, True)
	nx# = ex + TFormedX()
	ny# = ey + TFormedY()
	nz# = ez + TFormedZ()
	dx# = nx - ex
	dy# = ny - ey
	dz# = nz - ez
	
	hit = LinePick(ex, ey, ez, dx, dy, dz, 1)
	If hit
	nx = PickedX()
	ny = PickedY()
	nz = PickedZ()
	EndIf
	
	Camera\cx = Camera\cx + (nx - Camera\cx) * spd
	Camera\cy = Camera\cy + (ny - Camera\cy) * spd
	Camera\cz = Camera\cz + (nz - Camera\cz) * spd
	Camera\yaw# = EntityYaw(Camera\cam)
    PositionEntity Camera\cam, Camera\cx, Camera\cy, Camera\cz
	PointEntity Camera\cam, entity, 0	
End Function

Function CurveValue#(newvalue#,oldvalue#,increments)
	If increments>1 oldvalue#=oldvalue#-(oldvalue#-newvalue#)/increments
	If increments<=1 oldvalue=newvalue
	Return oldvalue#
End Function



Jerome Squalor(Posted 2007) [#3]
Thnx but can you add some comments or something?


Mortiis(Posted 2007) [#4]
If you want to understand it don't be "gimma da codez!!1" type programmer.Only way to learn it is to code it.Try to experiment with it and ask anything you couldn't do.Happy codings.


Jerome Squalor(Posted 2007) [#5]
thnx sorry.