void Start()
{
float distance = GetDistance(2, 2, 5, 6);
Debug.Log("(2,2)에서 (5,6)까지의 거리 : " + distance);
}
float GetDistance(float x1, float y1, float x2, float y2)
{
float width = x2 - x1;
float height = y2 - y1;
float distance = width * width + height * height;
distance = Mathf.Sqrt(distance);
return distance;
start 메소드에서
Debug.Log("(2,2)에서 (5,6)까지의 거리 : " + distance); 이렇게 되있잖아
여기어 distance에 들어가는 값이
GetDistance메소드의 마지막 줄에 있는 return distance의 값이야?
왜 그렇게 되?
이건...c#문제가 아닌데... 니가 맨 윗줄에 선언했구만
return 병신; 이라고 선언해도 똑같은값나옴ㅎㅎ 신기하지?
나 완전 초보라 잘몰라 ㅠㅠ
내가 궁금한게 뭐냐면 start매소드에서 distance 변수를 만들고
getdistance 매소드에서 또 distance를 만들었는데 그아래 return distance했을때 return한 값이 start매소드의 distance로 들어가는거야?
그러면 아래에서 return distance한 값은 어디로가는 거야? 어떻게 처리됨?
start메소드에서 맨처음 float형으로 선언한 distance로 가겠지
float distance = GetDistance(2, 2, 5, 6);
리턴한값을 받앗네요