to the power of 2

Hi!

What is the command that you use to calculate x^2, 2^2, 123123^2?

I am writing a code that destroys the player when he exists a circle. I am having some trouble writing the code since the equation of a circle is x^2+y^2 = r^2 and i cant find the command for “^” anywhere.

This is the code:

using UnityEngine;
using System.Collections;

public class OutsideArenaDeath : MonoBehaviour {

	private GameObject player;
	public float r = 6;
	private float x;
	private float y;

	void Update() {

		player = GameObject.FindGameObjectWithTag ("Player");
		x = player.transform.position.x;
		y = player.transform.position.y;

		if (//(x to the power of 2)+(y to the power of 2) > (r to the power of 2))
		{
		
			Destroy(player);

		}
}

Does anybody now how to make c# understand: (x to the power of 2)+(y to the power of 2) > (r to the power of 2)?

Thanks in advance!

Because just writing “THERE” with a link is not a very clear answer, let me say how you do :

Unity has a collection of common math functions inside the Mathf static class. From this class, you can find the following function to get the value of a float f raised to power p. :

public static float Pow(float f, float p);

See doc : Unity - Scripting API: Mathf.Pow

Otherwise, .Net proposes its Math.Pow method too (include using System at the top of your code to use it)

public static double Pow(
	double x,
	double y
)

See : Math.Pow(Double, Double) Method (System) | Microsoft Learn