Mathf.Sqrt

Switch to Manual

Declaration

public static float Sqrt(float f);

Parameters

f Real number whose square root to calculate.

Returns

float Real number whose square is f.

Description

Returns square root of f (real number whose square equals f).

When used with negative values, the output will be equal to NaN.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { // The formula made famous by Pythagoras, also used internally by // Vector3.Distance and several other standard functions. float HypotenuseLength(float sideALength, float sideBLength) { return Mathf.Sqrt(sideALength * sideALength + sideBLength * sideBLength); } }

Did you find this page useful? Please give it a rating: