Position of attached object
#2

Try this:
pawn Код:
/*
GetAttachedObjectPos

objectid - the objectid to which the attached object is attached to. (not the attached objectid)
Float:offset_x - the distance between the main object and the attached object in the X direction.
Float:offset_y - the distance between the main object and the attached object in the Y direction.
Float:offset_z - the distance between the main object and the attached object in the Z direction.
Float:x - the variable to store the X coordinate, passed by reference.
Float:y - the variable to store the Y coordinate, passed by reference.
Float:z - the variable to store the Z coordinate, passed by reference.
*/


stock GetAttachedObjectPos(objectid, Float:offset_x, Float:offset_y, Float:offset_z, &Float:x, &Float:y, &Float:z)
{
    new Float:object_px,
        Float:object_py,
        Float:object_pz,
        Float:object_rx,
        Float:object_ry,
        Float:object_rz;
    GetObjectPos(objectid, object_px, object_py, object_pz);
    GetObjectRot(objectid, object_rx, object_ry, object_rz);
    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_y * cos_z - offset_x * sin_x * sin_y * sin_z - offset_y * cos_x * sin_z + offset_z * sin_y * cos_z + offset_z * sin_x * cos_y * sin_z;
    y = object_py + offset_x * cos_y * sin_z + offset_x * sin_x * sin_y * cos_z + offset_y * cos_x * cos_z + offset_z * sin_y * sin_z - offset_z * sin_x * cos_y * cos_z;
    z = object_pz - offset_x * cos_x * sin_y + offset_y * sin_x + offset_z * cos_x * cos_y;
}
Thanks to YJIET.
Reply


Messages In This Thread
Position of attached object - by CONTROLA - 29.11.2012, 12:13
Re: Position of attached object - by GiamPy. - 29.11.2012, 12:15
Re: Position of attached object - by CONTROLA - 29.11.2012, 12:18
Re: Position of attached object - by GiamPy. - 29.11.2012, 12:22
Re: Position of attached object - by CONTROLA - 29.11.2012, 12:27
Re: Position of attached object - by GiamPy. - 29.11.2012, 12:29
Re: Position of attached object - by CONTROLA - 29.11.2012, 12:42
Re: Position of attached object - by GiamPy. - 29.11.2012, 13:21

Forum Jump:


Users browsing this thread: 1 Guest(s)