// Use this for initialization
 void Start()
 {
     //flipper = this.transform.Find ("Gun").GetComponent<GunFlipper> ();
     flipper        = GameObject.Find("Player/PlayerInvisible/Gun").GetComponent <GunFlipper> ();
     playerMovement = GameObject.Find("Player").GetComponent <PlayerMovement> ();
     playerInvis    = GameObject.Find("Player/PlayerInvisible");
 }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        flipper = this.transform.Find("Gun").GetComponent <GunFlipper> ();
        var dir   = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
        var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;

        if (Mathf.Abs(angle) < 90)
        {
            gunFlipped = false;
        }
        else
        {
            flipper.flipGun();
            gunFlipped = true;
        }
    }