Damn camera! Need help. -
Lewwy - 23.05.2009
When I try to set the camera to a certain point from where I was last facing, it turns to the right hand side of the screen instead of forwards.
How I store the coordinates in this variable:
pawn Код:
GetPlayerPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]);
GetPlayerFacingAngle(playerid, SavePos[playerid][picA]);
And here is the viewing:
pawn Код:
SetPlayerPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]+10); // so the player isn't visible.
SetPlayerFacingAngle(playerid, SavePos[playerid][picA]);
SetPlayerCameraPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]);
SetPlayerCameraLookAt(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]);
When viewed, it just turns to the right, do I need to set it to view the angle?
Halp!
Re: Damn camera! Need help. -
Weirdosport - 23.05.2009
You're telling the camera to look at where you put it... To set the camera facing in the same direction as the player, you'd need to use GetXYInFrontOfPlayer() or similar to get a co-ordinate in front of the player, then set the camera to look at that.
Re: Damn camera! Need help. -
Lewwy - 23.05.2009
Alright, I've heard of such a function. How would I save that into a variable though? The same way I did for the positioning for the player?
Re: Damn camera! Need help. -
Lewwy - 23.05.2009
Okay I've tried this function but I don't know what to do, I've searched but it's confusing me. An example would be great. (Sorry for the double post).
Re: Damn camera! Need help. -
samgreen - 24.05.2009
pawn Код:
SetPlayerPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]+10); // so the player isn't visible.
// SetPlayerFacingAngle() is unnecessary, this rotates the player in the world. We are dealing strictly with cameras.
SetPlayerCameraPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]);
#define DISTANCE 10.0
SetPlayerCameraLookAt(playerid, SavePos[playerid][picX] + DISTANCE * floatsin(-SavePos[playerid][picA], degrees), SavePos[playerid][picY] + DISTANCE * floatcos(-SavePos[playerid][picA], degrees), SavePos[playerid][picZ]);
This code calculates a new point that is DISTANCE away from the Camera's position, it makes use of the Camera facing angle you stored previously, and some laws of triangles. If you would like a more in-depth explanation let me know.
Changing DISTANCE to a larger value will change the Camera Look at location to a point that is farther away from the Camera.
Re: Damn camera! Need help. -
Lewwy - 24.05.2009
Thank you very much, works like a charm.
Re: Damn camera! Need help. -
Calgon - 15.08.2009
Quote:
|
Originally Posted by samgreen
pawn Код:
SetPlayerPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]+10); // so the player isn't visible.
// SetPlayerFacingAngle() is unnecessary, this rotates the player in the world. We are dealing strictly with cameras.
SetPlayerCameraPos(playerid, SavePos[playerid][picX], SavePos[playerid][picY], SavePos[playerid][picZ]);
#define DISTANCE 10.0 SetPlayerCameraLookAt(playerid, SavePos[playerid][picX] + DISTANCE * floatsin(-SavePos[playerid][picA], degrees), SavePos[playerid][picY] + DISTANCE * floatcos(-SavePos[playerid][picA], degrees), SavePos[playerid][picZ]);
This code calculates a new point that is DISTANCE away from the Camera's position, it makes use of the Camera facing angle you stored previously, and some laws of triangles. If you would like a more in-depth explanation let me know.
Changing DISTANCE to a larger value will change the Camera Look at location to a point that is farther away from the Camera.
|
Sorry to bump, but I couldn't find a relevant existing up-to-date thread that anyone had replied in.
I can't seem to get this working:
SetPlayerCameraLookAt(playerid, 1474.6978 + DISTANCE * floatsin(90, 90), -1713.1594 + DISTANCE * floatcos(90, 90), 8.2497);
Bit of a newbie question, sorry.