GetXYZInFrontOfObject ? - 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: GetXYZInFrontOfObject ? (
/showthread.php?tid=575685)
GetXYZInFrontOfObject ? -
FSAOskar - 29.05.2015
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
Re: GetXYZInFrontOfObject ? -
Vince - 29.05.2015
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.
AW: GetXYZInFrontOfObject ? -
Kaliber - 29.05.2015
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
AW: GetXYZInFrontOfObject ? -
FSAOskar - 29.05.2015
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