Пример #1
0
    Vector2 GetPosOnCompass(CompassMarkers marker)
    {
        Vector2 playerPos = new Vector2(player.transform.position.x, player.transform.position.z);
        Vector2 playerFwd = new Vector2(player.transform.forward.x, player.transform.forward.z);

        float angle = Vector2.SignedAngle(marker.position - playerPos, playerFwd);

        return(new Vector2(compassUnit * angle, 0f));
    }
Пример #2
0
    public void AddMarker(CompassMarkers marker)
    {
        GameObject newMarker = Instantiate(iconPrefab, compassImage.transform);

        marker.image        = newMarker.GetComponent <Image>();
        marker.image.sprite = marker.icon;

        compassMarkers.Add(marker);
    }