Hey dev forum, I’ve ran in to a problem that I can’t fix on my own. I need these eyes, (which are made out of two guis, one for the white and another for the pupil) specifically the pupil to face my mouse wherever it goes, and also stay inside of the white part of the eye. I have been searching for a solution for a while now, but I couldn’t find anything, the closest I got had a bug with the GuiInset that wasn’t explained. I put pictures below to show what I need.
The righthand pupils distance from the righthand side of the eye is the equivalent percentage to the cursors distance from the righthand side of the screen, but you have to take into account the padding between the edges of the eyes horizontal size and the cursors horizontal screen size (yellow squiggles). And also you have to account for the size of the nose from the center of the screen (blue squiggles). I only included the adjustments to horizontal movements in my image, the same adjustments must be made for the vertical movements of the mouse.
If you know the percentile size difference to map from and to then a generalised form is this:
((MAX - MIN) * PERCENT) + MIN
To calculate the new X position in the eyes (from the old position on the screen) then the form is:
OLD PERCENT = (x - OLD MIN) / (OLD MAX - OLD MIN)
NEW X = ((NEW MAX - NEW MIN) * OLD PERCENT) + NEW MIN
Where OLD_MIN is the screen minimum, OLD_MAX is the screen max, NEW_MIN is the eye min, and NEW_MAX is the eye max.
These will not account for padding or a big bit of the middle being out of bounds (i.e. the nose). And the units for both OLD and NEW must be the same.
With the navy blue representing the new min, and the maroon representing the new max, and using a render-stepped function, update them every frame? Or am I still not getting it?
Actually, forget that last post, I made that one late at night. After a lot of testing I got the percent values to line up pretty close (around a 2% difference, which I can assume is the nose gap you were talking about earlier) Anyways, I have both of the percents, but I don’t know how to move the eye to that position