HUD not consistant

Hey, I made my first Gmod HUD, and it looks pretty nice. I was ready to publish it, but I decided to throw it on my other computer. When I launched up the game mode, the HUD was completely screwed up and nothing was in the same place like on the other computer.

Any idea how to fix this? Here is how my code looks.

You need to take into account that other monitors use different resolutions, 984 and 240 would be at different positions on different screens. Take a look at ScrW() and ScrH(), which can present your current screen’s width and height. Acecool has some useful (and at times hard to read) documentation if he replies to the thread.



How exactly does this work? Do they redefine x/y everytime they make a new box in a new location? If you can explain the above, awesome :slight_smile:

In the example you quoted, the margin (not included in your quote) and the height (90 in your example) are subtracted from the Screen Height. For example, for a 1080p monitor, the y value would be 1080 - margin - 90.

// How to create huds

How to hard-code elements ( like you did ) and how to create and apply modifiers so it’ll scale properly between resolutions ( it won’t keep aspect ratio, that tutorial is coming soon )

Example: ( I need to fix the vertical alignment though )

Maybe you could use VGui to define your HUD positions more easely relative to screen width/height.

Anyway, I prefer to use the basic rendering. If you want me to correct your code, I’ll need the complete code of your HUD.

But it seams that you forgot to calculate your position using the ScrW/ScrH.

Give more code if you need help to implement those functions…