Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

AC user project: Compass pick-up item

Inspired by this thread:

... let's develop a compass pick-up item that integrates well with AC, and document the whole process here!


  • Initial ideas:

    • North is by default defined as world rotation 0
    • The compass must by default show North while taking into account the rotation of the main camera
    • It must be possible to redefine North as the direction to a specific GameObject from the main camera's current position
    • The compass must integrate well with AC's runtime system (vague/not quantifiable ... must be more specific)
    • A template must be provided to demonstrate the compass as part of the GUI
    • A template must be provided to demonstrate the compass as a 3D in-game object

    Hm, that's it for now ...

    Any ideas/requests from the 2D crowd?

  • edited September 2015
    Also, any thoughts on how you would actually want to be able use the compass in-game, and how it should work with the inventory?

    For my own project, I think it should be an item that can be picked up, and then gives you the option to switch a compass on and off as part of the GUI.
  • My version would basically be a "use" command on the compass in your inventory.  It would stop the player from moving and show the compass up on the screen while you were stopped.  You click again and it turns the compass off and you can move again.
  • Cool - shouldn't be too hard to do. Hope to have some time to get started on this later this week.
  • edited March 2016
    Another abandoned project eh @Snebjorn ?

    Just bugging >:)

    I'd also allow the player to be able to start moving whIle looking at compass - when the player moves compass automatically disappears.
  • edited March 2016
    Yeah yeah ... I actually wrote most of it, then got distracted.

    The funny thing is, I thought of bringing it into my current game project just the other day, but in a slightly changed form. It's a fantasy spoof setting where most people have MHDs (Magical Handheld Devices) as seen in this concept drawing:


    ... so basically a smartphone. :)
  • Did some slight updates to the original compass on this one but had a scripting question (since I'm basically an idiot).  I have two components on the main camera.  A rotating UI element (the arrow of the compass) and the non-rotating element (the "frame" of the compass that shows the directions).  This seems to work fine, however, I'm starting to think that it doesn't make sense for this to be on the main camera for my game.  Arkhangel is a series of static cameras that change via trigger.  That means the compass is camera justified and not player...however, if I put it on the player, then I need to make sure there's a way to turn it on/off.  I basically only want the compass to be on by default in the "overworld" maps and not the interior sub scenes...unless the player clicks on the compass in the inventory.
    What's a straight-forward method of doing that?  Should I overhaul how I'm doing this?
  • edited August 2016
    If you want to integrate it with inventory clicks, you'll probably want to move it to a Unity UI-based AC Menu, which you can then turn on and off using Actions when the inventory item is interacted with.

    If you simply use AC's Menu Manager to link up the Canvas object and set the Appear type to Manual, then you'll be able to control the UI's position and rotation through your own scripts without there being any conflict.
  • Thanks @ChrisIceBox.  How would I feed the player's position into this to the compass would animate based off of what direction the player is pointing?  Here's the original code that Mr. @Snebjorn provided awhile ago:


    using System.Collections;

    public class Compass : MonoBehaviour {


        public Texture compassTexture;

        public float screenPositionX = 50;

        public float screenPositionY = 50;


        void OnGUI()


            Vector2 compass_center = new Vector2(screenPositionX + compassTexture.width / 2, screenPositionY + compassTexture.height / 2);

            GUIUtility.RotateAroundPivot(-(transform.eulerAngles.y), compass_center);

            Rect compass_rect = new Rect(screenPositionX, screenPositionY, compassTexture.width, compassTexture.height);

            GUI.DrawTexture(compass_rect, compassTexture);



    I was going to try and add a child gameobject to the player and send a message to that to be on/off via the menu system.  The wiring is in place, but I'm guessing Send Message doesn't do anything for UI element's visibility.  Also tried setting the object up to Remember Visibility and defaulting it off and turning it on via Menu but that didn't work for me either.
  • Just a quick note about my code: instantiating a new compass_center and compass_rect each time OnGUI() is called is a Really Bad Idea[TM] - they should really be converted to class members instead.
  • The player's position can be gotten with KickStarter.player.transform.position
  • Okay cool.  Thanks all.  
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!