Page 1 of 1

Camera Entities

Posted: Thu Jan 22, 2015 11:30 pm
by Mit
Heres a simple example:

Code: Select all

Event( "Custom", "TestCam" )
{
	SpawnCamera()
}

Function	SpawnCamera(  )
{
	$xpos = $gPlayerWorldX + 100
	$ypos = $gPlayerWorldY + 1000
	
	$hCamEntity = EntityCreate( $gPlayerID, "LOCAL", "TRACK" )

	EntitySetPosition( $hCamEntity,  $xpos, $ypos, 0 )
	EntitySetValue( $hCamEntity, "ZOffset", 800 )
	EntitySetValue( $hCamEntity, "IsCamera", 1 )
	EntitySetValue( $hCamEntity, "FaceTarget", 1 )
	EntitySetValue( $hCamEntity, "AutoExpire", 5 )
	EntitySetValue( $hCamEntity, "Target", $gPlayerID )

	EntityAddToWorld( $hCamEntity )
}
New flags (in 0.69.9) are 'IsCamera' and 'AutoExpire' (time in seconds that the entity lasts for). The 'TRACK' behaviour keeps the entity/camera a fixed distance away from the target/player.