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!