SA-MP Forums Archive
Making an object face a certain point - 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: Making an object face a certain point (/showthread.php?tid=361618)



Making an object face a certain point - SuperViper - 21.07.2012

How would I go about making an object face a certain point? I need this for a new script I'm working on and I need the object to face the player.


Re: Making an object face a certain point - MerryDeer - 14.10.2016

Yes me too


Re: Making an object face a certain point - Freaksken - 14.10.2016

R = GetPlayerDistanceFromPoint
X1 = player x
Y1 = player y
X0 = object x
Y0 = object y
A = the angle you want to get
Код:
x1 = x0 + r * cos(a)
y1 = y0 + r * sin(a)
Rewrite the equation to retrieve a. Then set the objects' z-rotation.

Edit:
The equation is for 2D btw. In other words, a = z rotation of the object. For more info, search: point on edge of circle, on ******.
If you need 3D, search for the following on ******: point on edge of sphere.
Keep in mind the strange angle system in gta sa:
Quote:

Angles are reversed in GTA:SA; 90 degrees would be East in the real world, but in GTA:SA 90 degrees is in fact West. North and South are still 0/360 and 180. To convert this, simply do 360 - angle.

So once you have 'a', use the above mentioned conversion.


Re: Making an object face a certain point - MerryDeer - 14.10.2016

Give full function


Re: Making an object face a certain point - Logic_ - 14.10.2016

Make yourself, you have the formula -_-


Re: Making an object face a certain point - Freaksken - 14.10.2016

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
Give full function
Put in some effort.


Re: Making an object face a certain point - MerryDeer - 14.10.2016

This is too hard for my


Re: Making an object face a certain point - MerryDeer - 15.10.2016

And this formula is for coordinates? i need rotatations


Re: Making an object face a certain point - CoBra22 - 15.10.2016

i know one man hes good scripter but he off atm


Re: Making an object face a certain point - Freaksken - 15.10.2016

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
And this formula is for coordinates? i need rotatations
That's why I said to rewrite the equation so you could get the rotation.
If you don't know how to rewrite the equation (which is just math), then search on ******.