I'm currently reverse engineering a video game where what's rendered on the screen depends on the proximity of the player avatar to the camera. As such, for my freecam to work properly, I need to bring the player avatar along with the camera.
Since I can't yet find how the player avatar is rendered to the screen, the next best thing I can think to do is to place the player avatar behind the camera at all times (I suppose essentially like making the player avatar orbit the camera, but always be behind it).
I just can't quite pin down how to make this happen.
The values I have are as follows:
- Y (Up/Down)
- Y (Up/Down)
- Pitch (In degrees natively, but converted to radians for my calculations)
- Yaw (In degrees natively, but converted to radians for my calculations)
To get my camera to move forward in the direction I'm pointing my mouse when pressing the Y key, these are the calculations I'm using (code is in Lua):
--//Camera XYZ values local camCoordX = readFloat("[cameraBase]+990") --Camera X local camCoordY = readFloat("[cameraBase]+994") --Camera Y local camCoordZ = readFloat("[cameraBase]+998") --Camera Z --//Camera pitch and yaw local pitch = math.rad(readFloat("[cameraBase]+1540")) --Pitch local yaw = math.rad(readFloat("[cameraBase]+1544")) --Yaw --//Sine and cosine calculations local sinOfYaw = math.sin(yaw) --Sine of Yaw local cosOfYaw = math.cos(yaw) --Cosine of Yaw local sinOfPitch = math.sin(pitch) --Sine of Pitch local cosOfPitch = math.cos(pitch) --Cosine of Pitch --//If Y key is pressed, write new camera XYZ values accordingly if isKeyPressed(VK_Y) then writeFloat("[cameraBase]+990", camCoordX + (sinOfYaw * speed)) writeFloat("[cameraBase]+994", camCoordY - (sinOfPitch * speed)) writeFloat("[cameraBase]+998", camCoordZ + (cosOfYaw * speed)) end
Based on that information, is it feasible for me to accomplish placing the player avatar behind the camera at all times based on rotation? I'm open to other suggestions or options as well. Thank you for any help you can offer!