Camera pos problem
#1

Camera is not move when i clicked button. Why?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new Float:x, Float:y, Float:z;
	GetPlayerCameraPos(playerid, x, y, z);
	if(PRESSED(KEY_LEFT))
	{
		if(x == 340.62, y == -1805.01, z == 4.85)
		{
			SetPlayerCameraPos(playerid, 344.9864, -1804.2064, 5.0261);
			SetPlayerCameraLookAt(playerid, 345.4295, -1805.1089, 4.8861);
		}else if(x == 344.98, y == -1804.20, z == 5.02)
		{
			SetPlayerCameraPos(playerid, 347.9968, -1803.8370, 5.0931);
			SetPlayerCameraLookAt(playerid, 348.4687, -1804.7250, 4.9281);
		}else if(x == 347.99, y == -1803.83, z == 5.09)
		{
			SetPlayerCameraPos(playerid, 350.8560, -1804.5853, 4.8707);
			SetPlayerCameraLookAt(playerid, 351.4023, -1805.4297, 4.7207);
		}else if(x == 350.85, y == -1804.58, z == 4.87)
		{
			SetPlayerCameraPos(playerid, 354.1051, -1804.1498, 5.0500);
			SetPlayerCameraLookAt(playerid, 354.6397, -1805.0023, 4.8950);
		}
	}else if(PRESSED(KEY_RIGHT))
	{
		if(x == 354.10, y == -1804.14, z == 5.05)
		{
			SetPlayerCameraPos(playerid, 350.8560, -1804.5853, 4.8707);
			SetPlayerCameraLookAt(playerid, 351.4023, -1805.4297, 4.7207);
		}else if(x == 350.85, y == -1804.58, z == 4.87)
		{
			SetPlayerCameraPos(playerid, 347.9968, -1803.8370, 5.0931);
			SetPlayerCameraLookAt(playerid, 348.4687, -1804.7250, 4.9281);
		}else if(x == 347.99, y == -1803.83, z == 5.09)
		{
			SetPlayerCameraPos(playerid, 344.9864, -1804.2064, 5.0261);
			SetPlayerCameraLookAt(playerid, 345.4295, -1805.1089, 4.8861);
		}else if(x == 344.98, y == -1804.20, z == 5.02)
		{
			SetPlayerCameraPos(playerid, 340.6235, -1805.0142, 4.8561);
			SetPlayerCameraLookAt(playerid, 341.2792, -1805.7775, 4.7310);
		}
	}
	return 1;
}
Reply
#2

Movement keys (up, down, left, right) aren't detected by OnPlayerKeyStateChange, as it clearly states on the wiki. If you explicitly need those key, you'll probably want to use OnPlayerUpdate combined with some other variable to verify that the camera should change.

Also, you can't really compare floating point values like that because floats aren't exact. The x position retrieved from camerapos may be 340.619999. This isn't the same as 340.62 and thus the code will probably fail (I don't know the exact mechanics behind float comparison).
Reply
#3

So how can i do it?

now i have:
Код:
//OnPlayerUpdate

	new Float:x, Float:y, Float:z;
	new keys, ud, lr;
	GetPlayerKeys(playerid, keys, ud, lr);
	GetPlayerCameraPos(playerid, x, y, z);
	if(lr == KEY_LEFT)
	{
		if(x == 340.62, y == -1805.01, z == 4.85)
		{
			SetPlayerCameraPos(playerid, 344.9864, -1804.2064, 5.0261);
			SetPlayerCameraLookAt(playerid, 345.4295, -1805.1089, 4.8861);
		}else if(x == 344.98, y == -1804.20, z == 5.02)
		{
			SetPlayerCameraPos(playerid, 347.9968, -1803.8370, 5.0931);
			SetPlayerCameraLookAt(playerid, 348.4687, -1804.7250, 4.9281);
		}else if(x == 347.99, y == -1803.83, z == 5.09)
		{
			SetPlayerCameraPos(playerid, 350.8560, -1804.5853, 4.8707);
			SetPlayerCameraLookAt(playerid, 351.4023, -1805.4297, 4.7207);
		}else if(x == 350.85, y == -1804.58, z == 4.87)
		{
			SetPlayerCameraPos(playerid, 354.1051, -1804.1498, 5.0500);
			SetPlayerCameraLookAt(playerid, 354.6397, -1805.0023, 4.8950);
		}
	}else if(lr == KEY_RIGHT)
	{
		if(x == 354.10, y == -1804.14, z == 5.05)
		{
			SetPlayerCameraPos(playerid, 350.8560, -1804.5853, 4.8707);
			SetPlayerCameraLookAt(playerid, 351.4023, -1805.4297, 4.7207);
		}else if(x == 350.85, y == -1804.58, z == 4.87)
		{
			SetPlayerCameraPos(playerid, 347.9968, -1803.8370, 5.0931);
			SetPlayerCameraLookAt(playerid, 348.4687, -1804.7250, 4.9281);
		}else if(x == 347.99, y == -1803.83, z == 5.09)
		{
			SetPlayerCameraPos(playerid, 344.9864, -1804.2064, 5.0261);
			SetPlayerCameraLookAt(playerid, 345.4295, -1805.1089, 4.8861);
		}else if(x == 344.98, y == -1804.20, z == 5.02)
		{
			SetPlayerCameraPos(playerid, 340.6235, -1805.0142, 4.8561);
			SetPlayerCameraLookAt(playerid, 341.2792, -1805.7775, 4.7310);
		}
	}
Reply
#4

this--
Quote:
Directional keys do not trigger OnPlayerKeyStateChange (up/down/left/right). They can only be detected with GetPlayerKeys (in OnPlayerUpdate).
EDIT: dint saw ur last post and yes its done like that only but see the float thing that vince said
Reply
#5

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
this--
look up, man.

EDIT:
but still not work, i should replace check position another function, but idk how.
Reply
#6

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
look up, man.
sry didnt saw ur last post see the edit i made
Reply
#7

what i gotta do next, it is not work.
Reply
#8

anyone? please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)