Driggero Posted September 13, 2013 Posted September 13, 2013 Is it possible to take 2 sets of XYZ coordinates from the 3D world and find out the rotation values (x, y, z) needed to move between them. What I'm essentially looking for is this https://wiki.multitheftauto.com/wiki/FindRotation but working for 3D points. I'm using it to create a projectile from the players position to a point they've clicked on with the cursor. I've sussed all the rest of the code so I don't need help with that, just need to know if there's a way to find the rotation between 3D coordinates. Any help would be greatly appreciated!
.:HyPeX:. Posted September 13, 2013 Posted September 13, 2013 Is it possible to take 2 sets of XYZ coordinates from the 3D world and find out the rotation values (x, y, z) needed to move between them. What I'm essentially looking for is this https://wiki.multitheftauto.com/wiki/FindRotation but working for 3D points. I'm using it to create a projectile from the players position to a point they've clicked on with the cursor. I've sussed all the rest of the code so I don't need help with that, just need to know if there's a way to find the rotation between 3D coordinates. Any help would be greatly appreciated! you could use a math value.. it will be hard, since you already know the 2 positions.. EDIT//: the math value should be enought for facing the "distance", sorry, i'll be looking into rotation.
bandi94 Posted September 13, 2013 Posted September 13, 2013 Yes it is possbile , most common way to do that is : atan2f / atanf . Here is my old aimbot for some multiplayer FPS - game i played. The code is made in C++ , and for 3D camera , yaw/pitch/roll . This is just an exempel how could it be made. Ofc this must be edited to work on MTA , but it's a start for you what to search. D3DXVECTOR3 NewVector; NewVector.x = pClientInfo->g_pLocal->Pos.x - g_pESP.pPlayers[AimAt].Aimcords.x; NewVector.y = pClientInfo->g_pLocal->Pos.y - g_pESP.pPlayers[AimAt].Aimcords.y; NewVector.z = pClientInfo->g_pLocal->Pos.z - g_pESP.pPlayers[AimAt].Aimcords.z; float CamYaw = (float)atanf(NewVector.x/NewVector.z); if(NewVector.z > 0.0f && NewVector.x < 0.0f && CamYaw < 0.0f) CamYaw += D3DX_PI; else if(NewVector.z > 0.0f && NewVector.x > 0.0f) CamYaw += D3DX_PI; DWORD tempKey = 0; switch(AimbotKey) { default: tempKey = VK_LBUTTON; break; case 1: tempKey = VK_RBUTTON; break; case 2: tempKey = VK_SHIFT; break; } if((GetAsyncKeyState(tempKey) && !Aimbotkeyon) || (Aimbotkeyon)) { pClientInfo->g_pLocal->pitch = (float)atan2f(NewVector.y,(float)sqrt(pow(NewVector.z,2) + pow(NewVector.x,2))); pClientInfo->g_pLocal->yaw = CamYaw;
Driggero Posted September 13, 2013 Author Posted September 13, 2013 Yes it is possbile , most common way to do that is : atan2f / atanf . Here is my old aimbot for some multiplayer FPS - game i played. The code is made in C++ , and for 3D camera , yaw/pitch/roll . This is just an exempel how could it be made. Ofc this must be edited to work on MTA , but it's a start for you what to search. D3DXVECTOR3 NewVector; NewVector.x = pClientInfo->g_pLocal->Pos.x - g_pESP.pPlayers[AimAt].Aimcords.x; NewVector.y = pClientInfo->g_pLocal->Pos.y - g_pESP.pPlayers[AimAt].Aimcords.y; NewVector.z = pClientInfo->g_pLocal->Pos.z - g_pESP.pPlayers[AimAt].Aimcords.z; float CamYaw = (float)atanf(NewVector.x/NewVector.z); if(NewVector.z > 0.0f && NewVector.x < 0.0f && CamYaw < 0.0f) CamYaw += D3DX_PI; else if(NewVector.z > 0.0f && NewVector.x > 0.0f) CamYaw += D3DX_PI; DWORD tempKey = 0; switch(AimbotKey) { default: tempKey = VK_LBUTTON; break; case 1: tempKey = VK_RBUTTON; break; case 2: tempKey = VK_SHIFT; break; } if((GetAsyncKeyState(tempKey) && !Aimbotkeyon) || (Aimbotkeyon)) { pClientInfo->g_pLocal->pitch = (float)atan2f(NewVector.y,(float)sqrt(pow(NewVector.z,2) + pow(NewVector.x,2))); pClientInfo->g_pLocal->yaw = CamYaw; And there's me thinking it would be a few simple lines I'll certainly have a go at trying to make use of the math in your script and convert it into lua. Not very familiar with C++ so we'll see how that goes. Cheers for pointing me in the right direction
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now