예제 #1
0
        // Update is called once per frame
        void Update()
        {
            if (!m.m.inSlowDown)
            {
                this.speed = m.chargeSpeed;
            }

            clock = clock + Time.deltaTime;
            if (clock <= 1.3f)
            {
                if ((t.getY() - this.transform.position.y <= 0))
                {
                    float angle = Mathf.Rad2Deg * Mathf.Acos(Mathf.Abs(t.getY() - this.transform.position.y) / Mathf.Sqrt(Mathf.Pow((t.getX() - this.transform.position.x), 2) + Mathf.Pow((t.getY() - this.transform.position.y), 2)));
                    float sign  = (t.getX() - this.transform.position.x) / Mathf.Abs(t.getX() - this.transform.position.x);
                    transform.localEulerAngles = new Vector3(0, 0, 180 + (sign * (angle)));
                }
                else if ((t.getY() - this.transform.position.y > 0))
                {
                    float angle = Mathf.Rad2Deg * Mathf.Acos(Mathf.Abs(t.getY() - this.transform.position.y) / Mathf.Sqrt(Mathf.Pow((t.getX() - this.transform.position.x), 2) + Mathf.Pow((t.getY() - this.transform.position.y), 2)));
                    float sign  = (t.getX() - this.transform.position.x) / Mathf.Abs(t.getX() - this.transform.position.x);
                    transform.eulerAngles = new Vector3(0, 0, 0 + (sign * (angle) * -1));
                }
            }

            transform.Translate(Vector3.up * Time.deltaTime * speed);

            if (this.transform.position.x > 7 || this.transform.position.x < -7 || this.transform.position.y > 5 || this.transform.position.y < -5)
            {
                Destroy(this.gameObject);
            }
        }
예제 #2
0
 public float GetTargetX()
 {
     return(currentplayer.getX());
 }