HUD Compass?

Well, I am trying to make a hud and I want it to have a compass, but I have no idea how to do one.
I wanted to do a compass such as the one in fallout.

Any help is appreciated. :slight_smile:

Look at surface.drawrectuv. It’s what you need to do the fallout one.

surface.DrawTexturedRectUV

Not surface.DrawRectUV.

People can get confused if you rush your typing.

On another note, You don’t need to use surface.DrawTexturedRectUV to create a compass, There are other ways.

I believe the bigger problem is getting the enemies - in this case players and npc’s show up on the rectangle. I’m curious myself, because doing a top down compass/radar would be easier than translating it to 2D version, like fallout did.

In any case you’ll most likely need something to show specific parts of a map texture, using the UV mapping is the easiest and fastest thing to.

you could also map out an entire compass range from Left to right and use Scissor rects along with your eye angles, And compare that to the worlds Yaw Origin.

Scissor rects are generally slower than using uv mapping.

I wasn’t aware that compasses showed more than just direction.

He said compass not map. Dummys.

I’m working on one, but basically use GetAngles().y for yaw, and you can convert that to PI, where 2PI = full circle using math.deg or rad… Then, depending where you want north to be, you base the calculations of where each direction should be in the circle. Then you just output that data to a screen, make ranges of when each letter will be visible and then make the x for that letter be dynamic in the range of where it displays. That way you can have N move from left to right, and have W appear as N goes off your compass area. Same with S and E. You could also inject other letters for the in-between points NW, SW, NE, SE.

Usually if someone mentions “compass” here they mean a map instead.

The only thing you really need is the player angles, especially the yaw, if you want to be lazy you can simple make a texture and use http://wiki.garrysmod.com/page/Libraries/surface/DrawTexturedRectRotated

Something like this: http://steamcommunity.com/id/Acecool/screenshots/?appid=4000

http://cloud-2.steampowered.com/ugc/613880891250355774/FC9EFA8A7C9469A0CF40ACC662220CC4C801743D/
http://cloud-2.steampowered.com/ugc/613880891250355223/9D5383BDC8C47C79C1FF0CD28A9C5D3D01B27FF9/
http://cloud-2.steampowered.com/ugc/613880891250354374/DE5363B05B444F064666CCDC094D981F8CE3C9EB/

I’m still finalizing the math but that is done basically by figuring out positions of where the center of the compass is, translating the max left and right x value dependent of yaw, and the width of the compass. Eventually icon support will be added…

10min work lol.