How to change camera angle while it's attached to an object?
#1

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
Reply
#2

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.
Reply
#3

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)...
Reply
#4

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.
Reply
#5

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?
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=330879
Reply
#7

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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)