Scaling a HUD reticle with the screen to accurately represent spread in 3D

Godot Version

4.2.1

Question

I’m making a first-person player controller, and I’m stuck making my HUD UI match up with the world. My player has a TextureRect for a reticle (imagine a circular shotgun spread indicator, or some sort of “targeting area” in the middle of the screen). I’m able to have this scale with the screen size no problem by placing it in a container and using Stretch Mode viewport + Stretch Aspect expand in the project settings.

However, this means that making the window narrower will cause the reticle to shrink and no longer represent the same area in the world. This is a problem, since it needs to be accurate for the game’s mechanics to make sense.

Notably, this doesn’t seem to be a problem when making the window taller (i.e. changing height instead of width), since the view zooms in instead of extending and the proportions are maintained. I suppose this means the core of the problem is making the reticle scale only with screen height and not width? Although I’m not quite certain…

Any insights would be appreciated!

I ended up drawing the reticle dynamically with draw_line() instead of using a TextureRect, but the solution was indeed to have it scale with only the view height and not width.

This Reddit post is a good example: https://www.reddit.com/r/godot/comments/xtodjx/crosshair_circle_changing_with_gun_spread_using/

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.