Camera Vectors in R5 - how to use, READ THIS!
#6

CODE EDITED - THIS IS CORRECT AND TESTED!

Код:
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ,  Float:ObjX, Float:ObjY, Float:ObjZ,  Float:FrX, Float:FrY, Float:FrZ) {
	
	new Float:TGTDistance;
	
	// get distance from camera to target
	TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
	
	new Float:tmpX, Float:tmpY, Float:tmpZ;
	
	tmpX = FrX * TGTDistance + CamX;
	tmpY = FrY * TGTDistance + CamY;
	tmpZ = FrZ * TGTDistance + CamZ;
	
	return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
Код:
// EXAMPLE USAGE:

checkforcamera(PlayerID) {
	
	new Float:CameraPos[3];
	new Float:CameraFront[3];
	new Float:CheckObjectPos[3] = {-2661.2764,915.7676,79.6685}; // trash can near partyserver torenos
	
	GetPlayerCameraPos(PlayerID, CameraPos[0], CameraPos[1], CameraPos[2]);
	GetPlayerCameraFrontVector(PlayerID, CameraFront[0], CameraFront[1], CameraFront[2]);
	
	new Float:distc;
	distc = DistanceCameraTargetToLocation(CameraPos[0], CameraPos[1], CameraPos[2],  CheckObjectPos[0], CheckObjectPos[1], CheckObjectPos[2],  CameraFront[0], CameraFront[1], CameraFront[2]);
	
	new string[128];
	if (distc < 2.0) {
		format(string,sizeof(string),"YOU SEE IT.");
		SendClientMessage(PlayerID, COLOR_RED, string);
	}
	
	return true;
}
Reply


Messages In This Thread
Camera Vectors in R5 - how to use, READ THIS! - by JernejL - 24.03.2010, 18:20
Re: Camera Vectors in R5 - how to use, READ THIS! - by Norn - 24.03.2010, 18:42
Re: Camera Vectors in R5 - how to use, READ THIS! - by JernejL - 24.03.2010, 18:44
Re: Camera Vectors in R5 - how to use, READ THIS! - by wafffllesss - 24.03.2010, 18:47
Re: Camera Vectors in R5 - how to use, READ THIS! - by Norn - 24.03.2010, 19:23
Re: Camera Vectors in R5 - how to use, READ THIS! - by JernejL - 24.03.2010, 21:13
Re: Camera Vectors in R5 - how to use, READ THIS! - by CracK - 25.03.2010, 05:15
Re: Camera Vectors in R5 - how to use, READ THIS! - by Burridge - 25.03.2010, 07:08
Re: Camera Vectors in R5 - how to use, READ THIS! - by boelie - 25.03.2010, 19:18
Re: Camera Vectors in R5 - how to use, READ THIS! - by JernejL - 25.03.2010, 19:30
Re: Camera Vectors in R5 - how to use, READ THIS! - by boelie - 25.03.2010, 19:37
Re: Camera Vectors in R5 - how to use, READ THIS! - by MaykoX - 25.03.2010, 19:59
Re: Camera Vectors in R5 - how to use, READ THIS! - by Rac3r - 26.03.2010, 07:22
Re: Camera Vectors in R5 - how to use, READ THIS! - by CracK - 26.03.2010, 11:22
Re: Camera Vectors in R5 - how to use, READ THIS! - by ev0lution - 27.03.2010, 01:36
Re: Camera Vectors in R5 - how to use, READ THIS! - by Norn - 27.03.2010, 08:11
Re: Camera Vectors in R5 - how to use, READ THIS! - by ev0lution - 28.03.2010, 08:35
Re: Camera Vectors in R5 - how to use, READ THIS! - by ev0lution - 02.04.2010, 00:15
Re: Camera Vectors in R5 - how to use, READ THIS! - by SourceCode - 20.09.2011, 01:34
Re: Camera Vectors in R5 - how to use, READ THIS! - by JernejL - 28.09.2011, 21:05
Re: Camera Vectors in R5 - how to use, READ THIS! - by SourceCode - 15.11.2011, 13:45
Re: Camera Vectors in R5 - how to use, READ THIS! - by Banditukas - 02.11.2014, 12:00

Forum Jump:


Users browsing this thread: 10 Guest(s)