Set camera above object
#1

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

https://sampwiki.blast.hk/wiki/AttachCameraToObject
Reply
#3

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

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

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)