How to change camera angle while it's attached to an object? -
StRaphael - 19.12.2018
Hello, I need some help here
So when I attach player's camera to an object and I try to set the camera angle, it won't change the camera angle. The player is freezed.
I tried to change the camera angle with different methods(like with SetPlayerFacingAngle or SetPlayerCameraLookAt) but it won't work.
Any help please?How can I change the camera angle while it's attached to an object?
Thank you
Re: How to change camera angle while it's attached to an object? -
NaS - 19.12.2018
I'm pretty sure SetPlayerCameraLookAt works, but it will always freeze the camera so that the player cannot look around anymore.
You can "unfreeze" it by attaching it again but afaik it will "reset" the camera angle to face north again.
Re: How to change camera angle while it's attached to an object? -
StRaphael - 19.12.2018
Quote:
Originally Posted by NaS
I'm pretty sure SetPlayerCameraLookAt works, but it will always freeze the camera so that the player cannot look around anymore.
You can "unfreeze" it by attaching it again but afaik it will "reset" the camera angle to face north again.
|
Nope, it dosn't work...
PHP код:
CMD:objtest(playerid)
{
new Float:coordsfrom[3], Float:coordsto[3];
coordsfrom[0] = 2058.173828; coordsfrom[1] = 794.064025; coordsfrom[2] = 35.411571;
coordsto[0] = 2055.529785; coordsto[1] = 1132.966064; coordsto[2] = 40.313831;
SetPlayerCameraLookAt(playerid, coordsto[0], coordsto[1], coordsto[2], CAMERA_CUT);
SnowObject[playerid] = CreateDynamicObject(18864, coordsfrom[0], coordsfrom[1], coordsfrom[2], 0, 0, 0, -1, -1, -1, -1);
MoveDynamicObject(SnowObject[playerid], coordsto[0], coordsto[1], coordsto[2], 19);
AttachCameraToDynamicObject(playerid, SnowObject[playerid]);
TogglePlayerControllable(playerid, 0);
return 1;
}
This is one of the method I tried... what's wrong? The angle still not change(I think it remain blocked to North)...
Re: How to change camera angle while it's attached to an object? -
Threshold - 20.12.2018
You're changing the camera's LookAt before you even attach the camera. Try this:
PHP код:
CMD:objtest(playerid)
{
new
Float:coordsfrom[3] = {2056.173828, 794.064025, 35.411571},
Float:coordsto[3] = {2055.529785, 1132.966064, 40.313831}
;
TogglePlayerControllable(playerid, 0);
SnowObject[playerid] = CreateDynamicObject(18864, coordsfrom[0], coordsfrom[1], coordsfrom[2], 0, 0, 0, -1, -1, -1, -1);
AttachCameraToDynamicObject(playerid, SnowObject[playerid]);
MoveDynamicObject(SnowObject[playerid], coordsto[0], coordsto[1], coordsto[2], 19);
SetPlayerCameraLookAt(playerid, coordsto[0], coordsto[1], coordsto[2]);
return 1;
}
If this just results in your camera looking down or something similar, you might have to use a CAMERA_MOVE as a cut:
PHP код:
SetPlayerCameraLookAt(playerid, coordsto[0], coordsto[1], coordsto[2], CAMERA_MOVE);
Or alternatively look at
InterpolateCameraLookAt.
Re: How to change camera angle while it's attached to an object? -
StRaphael - 20.12.2018
Quote:
Originally Posted by Threshold
You're changing the camera's LookAt before you even attach the camera. Try this:
PHP код:
CMD:objtest(playerid)
{
new
Float:coordsfrom[3] = {2056.173828, 794.064025, 35.411571},
Float:coordsto[3] = {2055.529785, 1132.966064, 40.313831}
;
TogglePlayerControllable(playerid, 0);
SnowObject[playerid] = CreateDynamicObject(18864, coordsfrom[0], coordsfrom[1], coordsfrom[2], 0, 0, 0, -1, -1, -1, -1);
AttachCameraToDynamicObject(playerid, SnowObject[playerid]);
MoveDynamicObject(SnowObject[playerid], coordsto[0], coordsto[1], coordsto[2], 19);
SetPlayerCameraLookAt(playerid, coordsto[0], coordsto[1], coordsto[2]);
return 1;
}
If this just results in your camera looking down or something similar, you might have to use a CAMERA_MOVE as a cut:
PHP код:
SetPlayerCameraLookAt(playerid, coordsto[0], coordsto[1], coordsto[2], CAMERA_MOVE);
Or alternatively look at InterpolateCameraLookAt.
|
It tried this command and this happens :
https://www.youtube.com/watch?v=B1YhQOQvCQs
It's weird becouse it sets the camera on different position than player is, and the camera is no longer attached to the object.
Why? Any solution?
Re: How to change camera angle while it's attached to an object? -
Pottus - 21.12.2018
https://sampforum.blast.hk/showthread.php?tid=330879
Re: How to change camera angle while it's attached to an object? -
NaS - 21.12.2018
Quote:
Originally Posted by StRaphael
It tried this command and this happens : https://www.youtube.com/watch?v=B1YhQOQvCQs
It's weird becouse it sets the camera on different position than player is, and the camera is no longer attached to the object.
Why? Any solution?
|
Try to use SetPlayerCameraPos, after that SetPlayerCameraLookAt (which will update the camera) and finally attach it.
That should force the camera to point in a specific direction, but it always freezes the camera controls (there's no way around that sadly).
I did this for a much better camera drive than InterpolateCameraPos/-LookAt. I guess the order is crucial here.
Otherwise interpolating the camera should be the next best solution, eg. using the camera editor Pottus suggested.
Re: How to change camera angle while it's attached to an object? -
StRaphael - 21.12.2018
Quote:
Originally Posted by NaS
Try to use SetPlayerCameraPos, after that SetPlayerCameraLookAt (which will update the camera) and finally attach it.
That should force the camera to point in a specific direction, but it always freezes the camera controls (there's no way around that sadly).
I did this for a much better camera drive than InterpolateCameraPos/-LookAt. I guess the order is crucial here.
Otherwise interpolating the camera should be the next best solution, eg. using the camera editor Pottus suggested.
|
Yeah, it works like that, but I don't know why, when I set the camera position in the second position, it's looking again in the first position...
Anyway, thanks your help!
+rep