Esempio n. 1
0
    public void SetTargetWithSpeed(Vector3 point, float speed, bool useLowAngle)
    {
        currentSpeed = speed;

        Vector3 direction = point - firePoint.position;
        float   yOffset   = direction.y;

        direction = Math3d.ProjectVectorOnPlane(Vector3.up, direction);
        float distance = direction.magnitude;

        float angle0, angle1;
        bool  targetInRange = ProjectileMath.CalculateLaunchAngle(speed, distance, yOffset, Physics.gravity.magnitude, out angle0, out angle1);

        if (targetInRange)
        {
            currentRadian = useLowAngle ? angle1 : angle0;
        }

        projectileArc.UpdateArc(speed, distance, Physics.gravity.magnitude, currentRadian, direction, targetInRange);
        SetThrowPoint(direction, currentRadian * Mathf.Rad2Deg);
    }