Simulate "SyncRotation" positions
#1

Hello,

As you may know, the AttachObjectToObject has a "SyncRotation" parameter, which changes the position of the attached object when the base object is rotated. When I try to get the position of the attached object, the old position (before attaching) is displayed (GetObjectPos), so I can't get the positions with attaching a object to the first one.

Basically, I need something like
pawn Код:
GetPosFromObjectOffset( objectid, Float:oX, Float:oY, Float:oZ, &Float:X, &Float:Y, &Float:Z );
(which simulates SyncRotation when set to 1, so it changes the returned position based on the specified offsets and also based on the objectid's position and ROTATION).

I think this is why Incognito is also fixing this problem: https://github.com/samp-incognito/sa...ugin/issues/68 . I think he can't manage to do this calculation.
Reply
#2

Код:
stock GetAttachedObjectPos(Float: object_px, Float: object_py, Float: object_pz, Float: object_rx, Float: object_ry, Float: object_rz, Float:offset_x, Float:offset_y, Float:offset_z, &Float:x, &Float:y, &Float:z)
{
    new Float:cos_x = floatcos(object_rx, degrees),
        Float:cos_y = floatcos(object_ry, degrees),
        Float:cos_z = floatcos(object_rz, degrees),
        Float:sin_x = floatsin(object_rx, degrees),
        Float:sin_y = floatsin(object_ry, degrees),
        Float:sin_z = floatsin(object_rz, degrees);
    x = object_px + (offset_x * cos_z * cos_y) - (offset_x * sin_x * sin_y * sin_z) - (offset_y * sin_z * cos_x) + (offset_z * cos_z * sin_y) + (offset_z * sin_x * cos_y * sin_z);
    y = object_py + (offset_x * sin_z * cos_y) + (offset_x * sin_x * sin_y * cos_z) + (offset_y * cos_z * cos_x) + (offset_z * sin_z * sin_y) - (offset_z * sin_x * cos_y * cos_z);
    z = object_pz - (offset_x * sin_y * cos_x) + (offset_y * sin_x) + (offset_z * cos_y * cos_x);
}
I think this is what you need. However, I don't remember who came up with this function, maybe it's from Southclaw's SS gamemode.
Reply
#3

Yes, it's exactly what I wanted. Shame on me that I didn't know how to search that function by name, the name is pretty obvious.

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)