SA-MP Forums Archive
MoveObject Rotation Bug - 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: MoveObject Rotation Bug (/showthread.php?tid=604852)



MoveObject Rotation Bug - Darkwood17 - 10.04.2016

Hello,

I've created a object (barrier) and a command to move it's rotation only.
The problem is that the barrier immediately goes to position and movement is not seen.
The speed I use is 0.05, I also tried with lower values like 0.005 and 0.0005, but the movements still are unnoticeable or move non-smooth.

Код:
new barrier; // Setup the variable "barrier"
new Float:movespeed = 0.05; // Set the move speed of the barrier

public OnGameModeInit()
{
    AddPlayerClass(2, 1888.0, 1095.0, 11.0, 0, 0, 0, 0, 0, 0, 0);
    barrier = CreateObject(968, 1882.5, 1103.2, 10, 0, 0, 0); // Barrier (Opened)
    return 1;
}

CMD:barrier(playerid, params[])
{
    new status;
    if (sscanf(params, "i", status)) return SendClientMessage(playerid, -1, "0: Open; 1: Close");
    if (status == 0) // Open the barrier
    {
        MoveObject(barrier, 1882.5, 1103.2, 10, movespeed, 0.0, 0.0, 0.0);
        GameTextForPlayer(playerid, "~w~The barrier was opened~n~Rotation Y: ~r~0.0", 3000, 3);
    }
    if (status == 1) // Close the barrier 
    {
        MoveObject(barrier, 1882.5, 1103.2, 10, movespeed, 0.0, 90.0, 0.0); // Rotation Y is changed to 90.0
        GameTextForPlayer(playerid, "~w~The barrier was closed~n~Rotation Y: ~r~90.0", 3000, 3);
    }
    return 1;
}
Edit: Thanks to adri1


Re: MoveObject Rotation Bug - IstuntmanI - 10.04.2016

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

Quote:

This function can be used to make objects rotate smoothly. In order to achieve this however, the object must also be moved. The specified rotation is the rotation the object will have after the movement. Hence the object will not rotate when no movement is applied. For a script example take a look at the ferriswheel.pwn filterscript made by Kye included in the server package (SA-MP 0.3d and above).




Respuesta: MoveObject Rotation Bug - adri1 - 10.04.2016

Код:
CMD:barrier(playerid, params[])
{
    new status;
    if (sscanf(params, "i", status)) return SendClientMessage(playerid, -1, "0: Open; 1: Close");
    if (status == 0) // Open the barrier
    {
        MoveObject(barrier, 1882.5, 1103.2, 10+0.0001, movespeed, 0.0, 0.0, 0.0);
        GameTextForPlayer(playerid, "~w~The barrier was opened~n~Rotation Y: ~r~0.0", 3000, 3);
    }
    if (status == 1) // Close the barrier 
    {
        MoveObject(barrier, 1882.5, 1103.2, 10, movespeed, 0.0, 90.0, 0.0); // Rotation Y is changed to 90.0
        GameTextForPlayer(playerid, "~w~The barrier was closed~n~Rotation Y: ~r~90.0", 3000, 3);
    }
    return 1;
}
Change movespeed to 0.0001


Re: Respuesta: MoveObject Rotation Bug - Darkwood17 - 10.04.2016

Quote:
Originally Posted by adri1
Посмотреть сообщение
Код:
CMD:barrier(playerid, params[])
{
    new status;
    if (sscanf(params, "i", status)) return SendClientMessage(playerid, -1, "0: Open; 1: Close");
    if (status == 0) // Open the barrier
    {
        MoveObject(barrier, 1882.5, 1103.2, 10+0.0001, movespeed, 0.0, 0.0, 0.0);
        GameTextForPlayer(playerid, "~w~The barrier was opened~n~Rotation Y: ~r~0.0", 3000, 3);
    }
    if (status == 1) // Close the barrier 
    {
        MoveObject(barrier, 1882.5, 1103.2, 10, movespeed, 0.0, 90.0, 0.0); // Rotation Y is changed to 90.0
        GameTextForPlayer(playerid, "~w~The barrier was closed~n~Rotation Y: ~r~90.0", 3000, 3);
    }
    return 1;
}
Change movespeed to 0.0001
This actually is working. Reputation added to adri1 and IstuntmanI.


Respuesta: MoveObject Rotation Bug - adri1 - 10.04.2016

I did a function some time ago, you may find it useful

Quote:
Originally Posted by adri1
Посмотреть сообщение
pawn Код:
stock RotateObject(objectid, Float:rotX, Float:rotY, Float:rotZ, Float:Speed)
{
    new Float:X, Float:Y, Float:Z;
    new Float:SpeedConverted = floatmul(Speed, 0.01);
    GetObjectPos(objectid, X, Y, Z);
    SetObjectPos(objectid, X, Y, floatadd(Z, 0.01));
    MoveObject(objectid, X, Y, floatsub(Z, 0.01), SpeedConverted, rotX, rotY, rotZ);
    return 1;
}


//Para streamer
stock RotateDynamicObject(objectid, Float:rotX, Float:rotY, Float:rotZ, Float:Speed)
{
    new Float:X, Float:Y, Float:Z;
    new Float:SpeedConverted = floatmul(Speed, 0.01);
    GetDynamicObjectPos(objectid, X, Y, Z);
    SetDynamicObjectPos(objectid, X, Y, floatadd(Z, 0.01));
    MoveDynamicObject(objectid, X, Y, floatsub(Z, 0.01), SpeedConverted, rotX, rotY, rotZ);
    return 1;
}
Rotation Speeds:
0.01 - Rotaciуn muy lenta
1.00 - Velocidad normal (ideal para barreras, etc)
5.00 - Velocidad rбpida
Rotation Speeds:
0.01 - Slow
1.00 - Normal (ideal for barriers, etc)
5.00 - Fast


Re: MoveObject Rotation Bug - Darkwood17 - 10.04.2016

Thank you. This is really useful in my case.