Esempio n. 1
0
    public void SetTargetWithAngle(Vector3 point, float angle, int PlayerID)
    {
        currentAngle = angle;

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

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

        currentSpeed = ProjectileMath.LaunchSpeed(distance, yOffset, Physics.gravity.magnitude, angle * Mathf.Deg2Rad);

        projectileArc[PlayerID].UpdateArc(currentSpeed, distance, Physics.gravity.magnitude, currentAngle * Mathf.Deg2Rad, direction, true);
        SetTurret(direction, currentAngle);

        currentTimeOfFlight = ProjectileMath.TimeOfFlight(currentSpeed, currentAngle * Mathf.Deg2Rad, yOffset, Physics.gravity.magnitude);
    }
Esempio n. 2
0
    public void SetTargetWithSpeed(Vector3 point, float speed, bool useLowAngle, int PlayerID)
    {
        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.LaunchAngle(speed, distance, yOffset, Physics.gravity.magnitude, out angle0, out angle1);

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

        projectileArc[PlayerID].UpdateArc(speed, distance, Physics.gravity.magnitude, currentAngle, direction, targetInRange);
        SetTurret(direction, currentAngle * Mathf.Rad2Deg);

        currentTimeOfFlight = ProjectileMath.TimeOfFlight(currentSpeed, currentAngle, -yOffset, Physics.gravity.magnitude);
    }