Hi Unity Community!
Is is it possible to make a working compass in the hud for the player?
Thanks!
-Alias
Of course it’s possible. I’m sure there isn’t much that isn’t possible ![]()
If you look around a bit you’ll see that it’s been done many times by many people.
.
What sort of compass are you looking for? (I can think of at least three types: 2D arrow showing NSEW, 3D arrow showing the direction, overlaid display showing current angle from north that slides as you turn…)
I want something sort of like this;
~-NW------|-------N------|------NE-~
That scrolls from side to side around a cylinder shape.
Does that make sense to you, because it is sorta hard for me to explain.
Thanks!
I’ve attached a script that implements this type of compass (I actually wrote it months ago, but I seem to have forgotten to post it
). The script requires a long, thin texture containing a texture to represent the compass. You may need to experiment a bit with this to get the result you need.
339127–11875–$compass_144.js (588 Bytes)
That’s pretty neat, thanks for posting it ![]()
I can’t get it to work. This script must be atached to player gameObject, or MainCamera?
I can’t understand how it works exactly. ![]()
Texture must be all over screen width or can be only 1/3 in center of the screen? Like here http://images.bit-tech.net/content_images/2010/06/arma-ii-operation-arrowhead-review/0.jpg
The script will find the main camera regardless of which object it is attached to but it is proabably most logical to have it on the camera. As it stands, the script will display the compass across the whole width of the screen.
ok, thx. How would you make it to display only on the part of the screen? (like on the screenshot above)
thanks for posting.
(I’m replying to this old post since I’m having this problem too)
// Modify the X and Y values -->
// where 100, 200 is the position where you want to place it.
GUI.DrawTexture(new Rect(100, 200, texWidth, texHeight), compTex);
GUI.DrawTexture(new Rect(200, 300, texWidth, texHeight), compTex);