SA-MP Forums Archive
How to change camera angle while it's attached to an object? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to change camera angle while it's attached to an object? (/showthread.php?tid=661951)



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.173828coordsfrom[1] = 794.064025coordsfrom[2] = 35.411571;
    
coordsto[0] = 2055.529785coordsto[1] = 1132.966064coordsto[2] = 40.313831;
    
SetPlayerCameraLookAt(playeridcoordsto[0], coordsto[1], coordsto[2], CAMERA_CUT);
    
SnowObject[playerid] = CreateDynamicObject(18864coordsfrom[0], coordsfrom[1], coordsfrom[2], 000, -1, -1, -1, -1);
    
MoveDynamicObject(SnowObject[playerid], coordsto[0], coordsto[1], coordsto[2], 19);
    
AttachCameraToDynamicObject(playeridSnowObject[playerid]);
    
TogglePlayerControllable(playerid0);
    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.173828794.06402535.411571},
        
Float:coordsto[3] = {2055.5297851132.96606440.313831}
    ;
    
TogglePlayerControllable(playerid0);
    
SnowObject[playerid] = CreateDynamicObject(18864coordsfrom[0], coordsfrom[1], coordsfrom[2], 000, -1, -1, -1, -1);
    
AttachCameraToDynamicObject(playeridSnowObject[playerid]);
    
MoveDynamicObject(SnowObject[playerid], coordsto[0], coordsto[1], coordsto[2], 19);
    
SetPlayerCameraLookAt(playeridcoordsto[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(playeridcoordsto[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.173828794.06402535.411571},
        
Float:coordsto[3] = {2055.5297851132.96606440.313831}
    ;
    
TogglePlayerControllable(playerid0);
    
SnowObject[playerid] = CreateDynamicObject(18864coordsfrom[0], coordsfrom[1], coordsfrom[2], 000, -1, -1, -1, -1);
    
AttachCameraToDynamicObject(playeridSnowObject[playerid]);
    
MoveDynamicObject(SnowObject[playerid], coordsto[0], coordsto[1], coordsto[2], 19);
    
SetPlayerCameraLookAt(playeridcoordsto[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(playeridcoordsto[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