(adsbygoogle = window.adsbygoogle || []).push({});
So I am going to show you guys how to derive a formula that took me about 2 months awhile back to completely derive myself. By the end of this you will be all like "wtf 2 months?" but you gotta give it to me that there were a lot of other factors that went into how this works in different cases depending on what you are doing.
What does this formula do?
Gets the point x units in direction rotx,roty in 3D.
Uses:
GTA V mod menu uses - noclip, aimbot, seeing if a player is visible to you..... ect.
COD uses - aimbot.
Video Game Development Uses - Walking, noclip, making guns, making hands/placing stuff, anything involving getting where you are looking to....
So basically I find this very useful.
The
basic equation is this:
x = d*cos(xrot)*cos(yrot)
y = d*sin(yrot)
z = d*sin(xrot)*cos(yrot)
xrot is the players x view rotation and yrot is the players y view rotation.
x,y, and z are the offsets from 0,0,0 so if you did 1 as the distance (d) with a straight up angle it would return (0,1,0) and you just add that to some other coordinates.
Factors that affect the equation:
If the trig in your language is degrees or radians
The exact rotation is usually not perfectly correct so you may have to for example invert the yrot or subtract 90 degrees from the xrot ect...
Here is how it is derived. I will try my best to explain this.
SOH CAH TOA
If you know trig it will greatly help you to understand it.
Picture if this helps you understand why it uses right triangle trig:
You must login or register to view this content.
Extra note:
If you want to port this to a gta menu it would probably help if you understood how it works cuz gta has a weird coordinate system where the y and z are flip flopped.
I hope I helped somebody!