Esempio n. 1
0
        private void Update()
        {
            TownPlayer player = TownPlayer.instance();

            Vector2 v1 = new Vector2(this.transform.position.x, this.transform.position.z);
            Vector2 v2 = new Vector2(player.transform.position.x, player.transform.position.z);

            if (Vector2.Distance(v1, v2) < 4f)
            {
                // Close enough to display message.
                if (string.IsNullOrEmpty(this.textComponent.text))
                {
                    this.textComponent.text = this.getMessage();
                }

                Vector3 dir = player.transform.position - transform.position;
                dir.y = 0;
                Quaternion rot = Quaternion.LookRotation(dir);
                this.transform.rotation = Quaternion.Slerp(transform.rotation, rot, 5 * Time.deltaTime);
            }
            else
            {
                this.textComponent.text = string.Empty;
            }
        }
Esempio n. 2
0
        private void Awake()
        {
            TownPlayer.singleton = this;

            this.characterController = this.GetComponent <CharacterController>();
        }