2014-10-30 1 views
-1

임씨는 RTS 스타일 게임을하고 있으며 오류를 수정했습니다. 오류가 발생했습니다. 누군가 도와 주실 수 있습니까?Assets/Scripts/CameraOperator.cs (73,45) : 오류 CS0103 : 이름 'hit'이 (가) 현재 컨텍스트에 없습니다.

자산/스크립트/CameraOperator.cs (71,25) : 오류 CS0131 : 대입 측 변수, 속성 또는 인덱서

자산/스크립트/CameraOperator이어야 좌측 .cs (73,45) : 오류 CS0103이 : 이름은 '히트' 는 현재 컨텍스트 여기

에 존재하지 않는 것은 스크립트, 그리고 어떤 도움도 큰 BR 것입니다.

using UnityEngine; 
using System.Collections; 
using System.Collections.Generic; 

public class CameraOperator : MonoBehaviour 
{ 
    public Texture2D selectionHighlight = null; 
    public static Rect Selection = new Rect (0, 0, 0, 0); 
    private Vector3 StartClick = -Vector3.one; 
    private static Vector3 moveToDestination = Vector3.zero; 
    private static List<string> passables = new List<string>() {"Floor"}; 

    private void Update() 
    { 
     CheckCamera(); 
     CleanUp(); 
    } 

    private void CheckCamera() 
    { 
     if (Input.GetMouseButtonDown (0)) 
     { 
      StartClick = Input.mousePosition; 
     } 
     if (Input.GetMouseButtonUp (0)) 
     { 
      StartClick = -Vector3.one; 
     } 
     if (Input.GetMouseButton (0)) 
     { 
      Selection = new Rect (StartClick.x, InvertMouseY (StartClick.y), Input.mousePosition.x - StartClick.x, InvertMouseY (Input.mousePosition.y) - InvertMouseY (StartClick.y)); 
      if (Selection.width < 0) 
      { 
       Selection.x += Selection.width; 
       Selection.width = -Selection.width; 
      } 
      if (Selection.height < 0) 
      { 
       Selection.y += Selection.height; 
       Selection.height = -Selection.height; 
      } 
     } 
    } 
    float InvertMouseY (float y) 
    { 
     return Screen.height - y; 
    } 

    private void CleanUp() 
    { 
     if (!Input.GetMouseButtonUp (1)) { 
      moveToDestination = Vector3.zero; 
     } 
    } 
    public static Vector3 GetDestination() 
    { 
     if (moveToDestination == Vector3.zero) 
     { 
      RaycastHit hit; 
      Ray r = Camera.main.ScreenPointToRay (Input.mousePosition); 

      if (Physics.Raycast (r, out hit)) 
      { 
       while (!passables.Contains(hit.transform.gameObject.name)) 
       { 
        if (!Physics.Raycast (hit.transform.position, r.direction, out hit)) 
         break; 
       } 
      } 
     } 
     if(!hit.transform = null) 
     { 
      moveToDestination = hit.point; 
     } 
     return moveToDestination; 
    } 
} 
+0

오타를 확인하고 코드를 디버깅하는 것이 좋습니다. 지난 12 시간 동안 네 가지 질문을했는데 모두 단순한 오타였습니다. –

+0

오타는 다음 사람이 자습서를 작성했을 때 쉽게 만들 수 있습니다. –

+1

하지만 컴파일러는 오류가 발생한 행을 정확히 알려줍니다. 많은 오타가있는 자습서를 따르는 경우 새로운 자습서를 찾는 것이 좋습니다. 분명히 그것을 쓴 사람은 매우 조심스럽지 않고 혼란 스럽습니다. –

답변

0

"gameobject"의 "O"를 대문자로 입력해야한다고 생각합니다. 64 번째 줄에는 실제로 hit.transform.gameobject.name이 있습니다.

+0

일부 오류가 수정되어서 고맙습니다. –

관련 문제