SA-MP Forums Archive
Set camera above 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: Set camera above object (/showthread.php?tid=514962)



Set camera above object - fordawinzz - 24.05.2014

I'm not that good at this stuff (floatsin, floatcos). How to set the camera of a player above an object?


Re : Set camera above object - S4t3K - 24.05.2014

https://sampwiki.blast.hk/wiki/AttachCameraToObject


Re: Set camera above object - fordawinzz - 24.05.2014

I knew about it, but it is attaching the camera to the center of the object. I want it to be set above the object.


Re : Set camera above object - S4t3K - 24.05.2014

Then you have to use a timer with a small interval and SetPlayerCameraPos. It doesn't require any knowledge in mathemathics : just a few about the basic operations (+, -).

Get the object pos, then set the player camera pos to the position of this object + 1.0 more or less, and use a timer to repeat the operation.


Re: Set camera above object - fordawinzz - 24.05.2014

pawn Код:
command(test, playerid, params[]) {
    #pragma unused params
    new testobj = CreateObject(2942, 2045.48096, -1921.07983, 12.86420, 0.00000, 0.00000, 90.00000);
   
    AttachCameraToObject(playerid, testobj);
   
    SetTimerEx("MoveCamera", 500, true, "ii", playerid, testobj);
    return 1;
}

Func: MoveCamera(playerid, obj) {
    new
        Float: X, Float: Y, Float: Z;
   
    GetObjectPos(obj, X, Y, Z);
   
    SetPlayerCameraPos(playerid, X, Y, Z + 2.0);
    AttachCameraToObject(playerid, obj);
    return 1;
}
won't work


Re : Set camera above object - S4t3K - 24.05.2014

Because you've used "AttachCameraToObject".
Remove and it should work.


Re: Set camera above object - fordawinzz - 24.05.2014

The camera does not moves, I guess I should setplayercameralookat, too..