• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

CameraController 오류

21.02.26 00:23 작성 조회수 888

0

어제 이전 강의 듣고 나서 다시 켜니까 다음과 같은 오류가 뜨는데 도저히 이유를 모르겠습니다

Assets\Scripts\Controllers\CameraController.cs(5,14): error CS0101: The namespace '<global namespace>' already contains a definition for 'CameraController'

Assets\Scripts\Controllers\CameraController.cs(14,10): error CS0111: Type 'CameraController' already defines a member called 'Start' with the same parameter types

Assets\Scripts\Controllers\CameraController.cs(19,10): error CS0111: Type 'CameraController' already defines a member called 'LateUpdate' with the same parameter types

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

public class CameraController : MonoBehaviour
{
    [SerializeField]
    Define.CameraMode _mode = Define.CameraMode.QuaterView;
    [SerializeField]
    Vector3 _delta = new Vector3(3.75f, 7, -7); // the distance between the character and the camera
    [SerializeField]
    GameObject _player;

    void Start()
    {
        
    }

    void LateUpdate()
    {
        if (_mode == Define.CameraMode.QuaterView)
        {

            // Move the camera forward, closer to Player when Player gets occuluded by walls
            RaycastHit hit;
            if (Physics.Raycast(_player.transform.position, _delta, out hit, _delta.magnitude, LayerMask.GetMask("Wall")))
            {
                            // the distance between Player and the wall         // Make it a bit closer to Player from the wall
                float dist = (hit.point - _player.transform.position).magnitude * 0.8f;
                // Move the camera  // from Player, with the same direction towards Camera with the distance calucated above
                transform.position = _player.transform.position + _delta.normalized * dist;
            }

            else
            {
                transform.position = _player.transform.position + _delta;   // Have the camera follow the player
                transform.LookAt(_player.transform);
            }
        }
    }

    public void SetQuaterView(Vector3 delta)
    {
        _mode = Define.CameraMode.QuaterView;
        _delta = delta;
    }
}

답변 1

답변을 작성해보세요.

0

https://answers.unity.com/questions/479572/the-namespace-global-already-contains-a-definition.html

문제가 있을 땐 0순위로 구글에 메시지 이름을 비슷하게 검색해보시면 많은 도움이 됩니다.
CameraController라는 클래스가 어딘가에 중복해서 정의되지 않았는지 다시 확인해보시기 바랍니다.