I’m making a replay system and I’ve got everything down, I was originally tracking cursor position with mouse.x, mouse.y, however, the issue with this is if the recording was recorded with a viewport size of 1920x1080, that will then make it entirely inaccurate on another resolution.
This has to be very precise for the replay system to even be efficient, so any suggestions are appreciated.
I have tried converting the X and Y position of the mouse to scale which helps a lot, but still gives me a slight difference from actual content and replay.
I don’t know of an alternative to Mouse.x/y, but you could try to make a system where you get the ViewportSize and alter the Mouse.x/y coordinates so they are relative to the user’s ViewportSize. For example you could divide the Mouse.x coordinate by the current X dimension and then multiply by the new X dimension - this should mean that the ratio is the same, as well as their relative positions.
local newPosX = (Mouse.x/OldViewPort.x)*NewViewPort.x
local newPosY = (Mouse.y/OldViewPort.y)*NewViewPort.y
This is so close to what I need but for some reason, there’s a slight Y axis issue?
Originally I thought it made sense for it to be the GUI inset, but I set the recorded cursor’s Y to -36 and it was even further below the actual cursor.
I could just eye the offset between the recorded cursor and the actual one but I really would like an accurate solution to this.
Update, I’m now using scale which gives pretty much the same result, however, it works fine on the same resolution, yet when I use a different resolution it ends up at the top left.
The actual is recorded in studio on a pretty condensed window resolution, when I’m testing the replay I go test in game where it’s my actual resolution of 1920 x 1080.
It looks like the cursor position is stretching with the resolution but I don’t get why.
I can get the cursor to match up with the recording perfectly when testing on same resolution, so I’m pretty certain it’s just resolution scaling issues.
Interesting. There must be something else that’s causing the difference in position. Do you think it could be accounted for by the difference in ratios between the X/Y parts of the resolutions?
So, this is kind of on my end for not taking this into consideration.
But the cursor position worked fine, the math wasn’t wrong. The issue came from how a larger resolution will make you see more of the game instead of stretch your existing field of view.
If you go into a roblox game, stretch your window out, and then slowly drag it in, you’ll start to notice you see less and less of what you could see, instead of seeing them smaller.
In summary the solution I’m opting for now is recording a vector3 position of where the mouse hits, and then using world to screen point to get the correct x + y. Gonna mark yours as a solution since it’s the correct answer though, appreciate it!