hello, so i am currently making a cheat for Pixel Gun3D and i'm making a ESP mod which uses Unity's WorldToScreenPoint function
public Vector3 WorldToScreenPoint(Vector3 position)
{
Vector3 result;
return result;
}
i am using the one above and here is my code for calling it
Vector3 screenPos = WorldToScreenPoint(get_cam(), position);
the position is the enemy's position but then the worldtoscreen's return isnt accurate so i do this to get a better result
float xPos = screenPos.X- (SCREEN_WIDTH * 0.5); // SCREEN_WIDTH - (SCREEN_WIDTH - screenPos.X);
float yPos = SCREEN_WIDTH - screenPos.Y;
then draw it with ImGui:
ImVec2 startPoint = ImVec2((SCREEN_WIDTH / 2), 5);
ImVec2 endPoint = ImVec2(xPos, yPos);
ImGui::GetBackgroundDrawList()->AddLine(startPoint, endPoint, [self getImU32:Color::Black], 2.0f);
it still doesnt work like expected because it draws lines to places that are/arent near the enemy (picture below)
if anyone could help me to calculate the actual screen position i'd really apppreciate it