Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

(Call of Duty-esque) Directional Indicator

Discussion in 'Scripting' started by rtainc, Jun 4, 2014.

  1. rtainc

    rtainc

    Joined:
    Jul 15, 2013
    Posts:
    16
    Hi! I'm at a complete loss on this. I would like to implement a circular direction indicator, like in Call of Duty's hit indication. It would work by getting two points, the 'player' position, and the 'target' position. It would require allowing more than one target position. (Contrary to the image, Origin would have to include rotation as well as position, for the direction indicators to be correctly facing.

     
    Last edited: Jun 4, 2014
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. A.Killingbeck

    A.Killingbeck

    Joined:
    Feb 21, 2014
    Posts:
    483
    Or if you know the world position of the thing that shot you, you can then use WorldToScreenPoint/WorldToViewportPoint and rotate the gui towards that screen position.
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    do they work if the world position isn't within the camera's view i.e. being shot in the back etc.? I've always assumed they didn't...
     
  5. A.Killingbeck

    A.Killingbeck

    Joined:
    Feb 21, 2014
    Posts:
    483
    Yes, The Z component of the returned Vector3 is the position in world units from the camera. If this is <0 the object is behind the camera, otherwise it is infront