GetXYZInFrontOfObject ?
#1

Hey,
could anyone help me with a small calculation ? I need a function like GetXYZInFrontOfObject. I tried to modify my GetXYInFrontOfObject function but I failed. Could anyone help me ?
The Z-Coordinate should be based on the Y-Angle of the object. So not only on the Z one.

Thanks in advance
Reply
#2

I believe you need to use atan2 for that, although that function is coincidentally not documented on the wiki ... I'm not too good with trigonometry, so someone else may want to expand or correct my answer.
Reply
#3

It's simpler, just a short explanation:

Код:
CreateObject(modelid,x,y,z,r1,r2,r3);
Код:
//So you have to do this:
stock GetXYInFrontOfObject(objectid, r3, &Float:x, &Float:y, Float:distance)
{
    new Float:z;
#if !defined STREAMER_OBJECT_TYPE_DYNAMIC
    GetObjectPos(objectid, x, y, z);
#else
    GetDynamicObjectPos(objectid, x, y, z);
#endif
    x += (distance * floatsin(-r3, degrees));
    y += (distance * floatcos(-r3, degrees));
}
Greekz
Reply
#4

Thanks for the answer but I've got that code already and I wanna add a parameter for the Z-Coordinate also which should get calculated from the Y-Angle of the object
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)