Sorry if this is the incorrect place to ask this question. I’m very new to game making in general.
I cant find much info online but essentially I’m making a 2D point and click game puzzle like game.
I was hoping to add a feature where I could create these basic eyes in the wall of my background that would open and follow a players movement in a room when the player isnt facing the eyes in their direction:
I am a complete newbie to everything on unreal and have limited knowledge.
i’ve never done 2d in unreal. so i dont know how the actual code will work. but you will basically layer the parts of the eyes. the eyeball will be a rectangle on the bottom layer. the eyeball will need to be larger than the eye itself so it has room to move. the eyelids will layer over top and will need to be large enough to cover the parts of the eyeball you don’t want to be shown.
Now store float values for the position the eye will be in at the top most position, bottom most position, left most and right most. and a 2dvector for the center position. now take the player position on screen and push that thru some math to come up with where the eyeball will be to simulate the eye tracking the player using.
the math you would take the distance from the world location of the eyeball to the player on each plane (x,y) seperately, compare those to the distance of the eyeball to the screen edge. then use that percentage to adjust the eyeball position based on center and max stored valued.
this math could potentially be dumbed down, be less acurate but maybe still good enough to look good, and just move the eyeballs based on player position in the viewport instead of calculating distances every frame.