Jump to content
dimon

[Help]how to set the camera at eye

Recommended Posts

how to set the camera at eye level and looking where the player looks?

Share this post


Link to post
Share on other sites
player remoteControl _unit;
_unit switchCamera "internal";
objNull remoteControl _unit; // removes the remoteControlling
// whatever happens in between
player switchCamera "internal";  // returns to the player

 

Share this post


Link to post
Share on other sites

getCameraViewDirection

 

nul = this spawn {
	params[ "_unit" ];
	
	_camera = "camera" camCreate ASLToAGL eyePos _unit;
	_camera cameraEffect["INTERNAL", "BACK", "myrender"];
		
	_billboard = createVehicle [ "UserTexture1m_F", ( _unit getPos[ 3, ( getDir _unit ) ] ) vectorAdd [ 0, 0, 1 ], [], 0, "CAN_COLLIDE" ];
	_billboard setDir ( _unit getDir _billboard );
	_billboard setObjectTextureGlobal[ 0, "#(argb,512,512,1)r2t(myrender,1.0)" ];
	
	TAG_fnc_updateCamera = {
		params[ "_unitNetID", "_cameraNetID", "_BBNetID" ];
		
		_unit = _unitNetID call BIS_fnc_objectFromNetId;
		_camera = _cameraNetID call BIS_fnc_objectFromNetId;
		_billBoard = _BBNetID call BIS_fnc_objectFromNetId;
		
		_camera camSetPos (( ASLToAGL eyePos _unit ) vectorAdd (( getCameraViewDirection _unit ) vectorMultiply 0.5 ));
		_camera camSetDir ( getCameraViewDirection _unit );
		_camera camCommit 0;
		
		_billboard setPos (( ASLToAGL eyePos _unit ) vectorAdd (( getCameraViewDirection _unit ) vectorMultiply 3 ));
		_billboard setVectorDirAndUp [ getCameraViewDirection _unit, getCameraViewDirection _unit vectorCrossProduct vectorNormalized ( _unit modelToWorld[1,0,0] ) ];
	};
	
	addMissionEventHandler [ "EachFrame", format[ "
		[ '%1', '%2', '%3' ] call TAG_fnc_updateCamera;
	", _unit call BIS_fnc_netId, _camera call BIS_fnc_netId, _billboard call BIS_fnc_netId ]];
};

In a units init box for testing. Ignore the billboard flipping up side down when turning, that is just my horrendous vector maths :smile_o: . Just wanted to provide a visual example. Maybe someone will chip in and fix it.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×