예제 #1
0
    private void FixedUpdate()
    {
        if (rocketType == RocketType.Guided)
        {
            rb.velocity        = (Target.transform.position - transform.position).normalized * speed;
            transform.rotation = Quaternion.LookRotation(rb.velocity) * Quaternion.Euler(rocketRotation);
        }
        else if (rocketType == RocketType.HitByBat || rocketType == RocketType.HitByOther)
        {
            var rot = rb.rotation;
            rot.z += 100 * Time.fixedDeltaTime;
            rb.rotation.Set(rot.x, rot.y, rot.z, rot.w);

            explodeInSec -= Time.fixedDeltaTime;
            destroyInSec -= Time.fixedDeltaTime;
            if (explodeInSec < 0)
            {
                audioSource.Stop();
                explodeRocket();
                explodeInSec = 1000;
            }

            if (destroyInSec < 0)
            {
                RocketFactory.DestroyRocket(gameObject);
                DexplodeRocket();

                destroyInSec = 1000;
            }
        }
    }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(DestroyKey))
     {
         RocketFactory.DestroyRocket(gameObject);
     }
 }
예제 #3
0
 private void OnTriggerEnter(Collider other)
 {
     Debug.Log("Trigger!!! " + other.gameObject.tag);
     if (other.gameObject.tag == "Enemy")
     {
         RocketFactory.DestroyRocket(other.gameObject);
     }
 }