Ejemplo n.º 1
0
    Vector3 Intercept(float bulletSpeed)
    {
        InterceptionSystem interceptor = new InterceptionSystem();

        if (shipTarget != null)
        {
            return(interceptor.CalculateInterceptPosition(shipTarget.position, shipTarget.GetComponent <Rigidbody>().velocity, transform.position, bulletSpeed));
        }

        return(Vector3.zero);
    }
    // Update is called once per frame
    void Update()
    {
        if (target != null)
        {
            if (timer > 0)
            {
                timer -= Time.deltaTime;
            }

            InterceptionSystem interceptor = new InterceptionSystem();
            Vector3            aimPoint    = interceptor.CalculateInterceptPosition(target.position, target.GetComponent <Rigidbody>().velocity, transform.position, bulletModule.BulletVelocity);
            //float passed = Vector3.Dot(aimPoint, aimPoint - transform.position);
            //if(passed > 0)
            //{
            transform.Rotate(AimAtTarget(aimPoint) * turnSpeed * Mathf.Clamp(timer / homingLifetime, 0.1f, 1));
            //}
        }
    }