안녕하세요. 현재 프로젝트 진행중이라 강의를 잠시 쉬고 있지만 정말 큰 도움을 받아서 감사드립니다. ^^여쭤보고 싶은게 있어서요. 강의 외 질문이 있어서. 여쭤봅니다. Resources폴더에 scriptable파일을 15개 정도 두고 게임을 진행했는데 Resources.LoadAll이 함수에서 계속 걸려서 앞으로 나가지를 못하네요. 왜이렇게 시간이 걸리는건지?? 구글링 해 보니 대규모 프로젝트에서는 addressable을 많이 사용한다는데 파일 15개정도를 로드하는 것을 대규모라고 볼 수는 없을 것 같은데요. 조언 구합니다.
dqn 학습 부분에서, index에러가 자꾸 납니다.. dqn.py는 github에 올려져 있는 것을 그대로 사용했습니다. < 에러 코드 > (colab) C:\Users\pss60\Desktop\ML-Agents_Project\agents>python dqn.py Traceback (most recent call last): File "C:\Users\pss60\Desktop\ML-Agents_Project\agents\dqn.py", line 218, in <module> state = preprocess(dec.obs[OBS], dec.obs[GOAL_OBS]) IndexError: list index out of range < GridAgent > using System; using UnityEngine; using System.Linq; using Unity.MLAgents; using Unity.MLAgents.Sensors; using Unity.MLAgents.Actuators; using UnityEngine.Rendering; using UnityEngine.Serialization; using System.Collections.Generic; public class GridAgent : Agent { [FormerlySerializedAs("m_Area")] [Header("Specific to GridWorld")] public GridArea area; public float timeBetweenDecisionsAtInference; float m_TimeSinceDecision; [Tooltip("Because we want an observation right before making a decision, we can force " + "a camera to render before making a decision. Place the agentCam here if using " + "RenderTexture as observations.")] public Camera renderCamera; VectorSensorComponent m_GoalSensor; private Transform agentTrans = null; private Vector3 moveRight = new Vector3(1, 0, 0); private Vector3 moveLeft = new Vector3(-1, 0, 0); private Vector3 moveUp = new Vector3(0, 0, 1); private Vector3 moveDown = new Vector3(0, 0, -1); public enum GridGoal { GreenPlus, RedEx, } // Visual representations of the agent. Both are blue on top, but different colors on the bottom - this // allows the user to see which corresponds to the current goal, but it's not visible to the camera. // Only one is active at a time. public GameObject GreenBottom; public GameObject RedBottom; GridGoal m_CurrentGoal; public GridGoal CurrentGoal { get { return m_CurrentGoal; } set { switch (value) { case GridGoal.GreenPlus: GreenBottom.SetActive(true); RedBottom.SetActive(false); break; case GridGoal.RedEx: GreenBottom.SetActive(false); RedBottom.SetActive(true); break; } m_CurrentGoal = value; } } [Tooltip("Selecting will turn on action masking. Note that a model trained with action " + "masking turned on may not behave optimally when action masking is turned off.")] public bool maskActions = true; const int k_NoAction = 0; // do nothing! const int k_Up = 1; const int k_Down = 2; const int k_Left = 3; const int k_Right = 4; EnvironmentParameters m_ResetParams; public override void Initialize() { m_GoalSensor = this.GetComponent<VectorSensorComponent>(); m_ResetParams = Academy.Instance.EnvironmentParameters; } public override void CollectObservations(VectorSensor sensor) { Array values = Enum.GetValues(typeof(GridGoal)); int goalNum = (int)CurrentGoal; // 현재 에이전트의 x, y 좌표 위치 값을 관측 정보에 추가 sensor.AddObservation(agentTrans.position.x); sensor.AddObservation(agentTrans.position.z); // 각각 도형에 대한 좌표 위치 값을 관측 정보에 추가 List<int> otherPos = area.otherPos; for (int i = 0; i < otherPos.Count; i++) sensor.AddObservation(otherPos[i]); // 목표 지점에 대한 정보 m_GoalSensor.GetSensor().AddOneHotObservation(goalNum, values.Length); } public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask) { // Mask the necessary actions if selected by the user. if (maskActions) { // Prevents the agent from picking an action that would make it collide with a wall var positionX = (int)agentTrans.localPosition.x; var positionZ = (int)agentTrans.localPosition.z; var maxPosition = (int)m_ResetParams.GetWithDefault("gridSize", 5f) - 1; if (positionX == 0) { actionMask.SetActionEnabled(0, k_Left, false); } if (positionX == maxPosition) { actionMask.SetActionEnabled(0, k_Right, false); } if (positionZ == 0) { actionMask.SetActionEnabled(0, k_Down, false); } if (positionZ == maxPosition) { actionMask.SetActionEnabled(0, k_Up, false); } } } // to be implemented by the developer public override void OnActionReceived(ActionBuffers actionBuffers) { // 매 행동마다 -0.01 보상(패널티) 부여 AddReward(-0.01f); var action = actionBuffers.DiscreteActions[0]; // 에이전트가 이동하게 될 위치 값을 저장할 변수 (Vector3) var targetPos = agentTrans.position; switch (action) { case k_NoAction: // do nothing break; case k_Right: // 부여받은 행동이 오른쪽이라면, targetPos = agentTrans.position + moveRight; // 현재 위치에서 1만큼 x축 방향으로 설정 break; case k_Left: targetPos = agentTrans.position + moveLeft; break; case k_Up: targetPos = agentTrans.position + moveUp; break; case k_Down: targetPos = agentTrans.position + moveDown; break; default: throw new ArgumentException("Invalid action value"); } var hit = Physics.OverlapBox( targetPos, new Vector3(0.3f, 0.3f, 0.3f)); // 벽에 부딪히지 않았다면, if (hit.Where(col => col.gameObject.CompareTag("wall")).ToArray().Length == 0) { // 정해진 위치로 이동 agentTrans.position = targetPos; // +오브젝트 만났다면, if (hit.Where(col => col.gameObject.CompareTag("plus")).ToArray().Length == 1) { ProvideReward(GridGoal.GreenPlus); EndEpisode(); } // x오브젝트 만났다면, else if (hit.Where(col => col.gameObject.CompareTag("ex")).ToArray().Length == 1) { ProvideReward(GridGoal.RedEx); EndEpisode(); } } } private void ProvideReward(GridGoal hitObject) { if (CurrentGoal == hitObject) { SetReward(1f); } else { SetReward(-1f); } } // WASD 키보드로 에이전트 이동 public override void Heuristic(in ActionBuffers actionsOut) { var discreteActionsOut = actionsOut.DiscreteActions; discreteActionsOut[0] = k_NoAction; if (Input.GetKey(KeyCode.D)) { discreteActionsOut[0] = k_Right; } if (Input.GetKey(KeyCode.W)) { discreteActionsOut[0] = k_Up; } if (Input.GetKey(KeyCode.A)) { discreteActionsOut[0] = k_Left; } if (Input.GetKey(KeyCode.S)) { discreteActionsOut[0] = k_Down; } } // to be implemented by the developer public override void OnEpisodeBegin() { area.AreaReset(); Array values = Enum.GetValues(typeof(GridGoal)); CurrentGoal = (GridGoal)values.GetValue(UnityEngine.Random.Range(0, values.Length)); } public void FixedUpdate() { WaitTimeInference(); } void WaitTimeInference() { if (renderCamera != null && SystemInfo.graphicsDeviceType != GraphicsDeviceType.Null) { renderCamera.Render(); } if (Academy.Instance.IsCommunicatorOn) { RequestDecision(); } else { if (m_TimeSinceDecision >= timeBetweenDecisionsAtInference) { m_TimeSinceDecision = 0f; RequestDecision(); } else { m_TimeSinceDecision += Time.fixedDeltaTime; } } } }
안녕하세요 다른 분야 개발중인데 흥미가 생겨서 수강하게 되었습니다 다름이 아니라 초반 세팅을 하면서 궁금한 점이 생겨서 문의를 남기게 되었는데요 현재(2025년 5월 26일) 기준으로 설치 가능한 유니티6 버전이 LTS인 6.0(6000.0.49f1) Supported인(하지만 추천딱지가 붙어있는) 6.1(6000.1.3f1) 이렇게 두종류가 있던데 강의는 아무 버전으로 들어도 진행에 무리가 없을까요? 두번째로 첫 프로젝트를 생성하는 과정에서 템플릿을 선택할때 저는 Universal 2D가 가장 위에 있던데, 상관없이 2D (Built-in Render Pipeline)을 선택하면 될까요? 그걸 눌렀을때 오른쪽에 프로젝트 세팅 화면이 안나오고 템플릿을 다운로드 받으라는 버튼이 뜨길래 여쭤봅니다 감사합니다
좋은 강의 감사드립니다. 현재 설계 상 각 씬마다 LobbyUIController, InGameUIController 각각 해당 씬의 UI 캔버스를 가지고 해당 씬 고유의 UI 를 그리고, UIManager 또한 스스로의 캔버스를 가지고 DontDestroyOnLoad 에 남아서 여러 씬에서 공통적으로 사용되는 UI 를 그리고 있는데요. UIManager 가 DontDestroyOnLoad 에 상주하면서 모든 UI 를 그리는 구조와 비교했을 때 장단점이 무엇일지 여쭤보고 싶습니다. 캔버스와 카메라가 많은 것보다 UI 관련 캔버스를 하나로 통일하고 싶은데 스스로 생각해보아도 두 설계의 장단점에 대해 구체적으로 결론내리기가 어려웠습니다. 감사합니다!
void RegisterSend() { if (_disconnected == 1) return; while (_sendQueue.Count > 0) { ArraySegment<byte> buff = _sendQueue.Dequeue(); _pendingList.Add(buff); } _sendArgs.BufferList = _pendingList; try { bool pending = _socket.SendAsync(_sendArgs); if (pending == false) OnSendCompleted(null, _sendArgs); } catch (Exception e) { Console.WriteLine($"RegisterSend Failed {e}"); } } void OnSendCompleted(object sender, SocketAsyncEventArgs args) { lock (_lock) { if (args.BytesTransferred > 0 && args.SocketError == SocketError.Success) { try { _sendArgs.BufferList = null; _pendingList.Clear(); OnSend(_sendArgs.BytesTransferred); if (_sendQueue.Count > 0) RegisterSend(); } catch (Exception e) { Console.WriteLine($"OnSendCompleted Failed {e}"); } } else { Disconnect(); } } } 해당 코드에 대한 질문이 있습니다. RegisterSend에서 sendQueue에 있는 패킷들을 다 빼내서 pendingList에 넣고 pendingList를 args.BuffList로 설정합니다. 이후 OnSendComplete에 처리에 의문이 있습니다. TCP 특성상 부분 전송이 이루어질 수 있다고 생각합니다. 부분 전송이 일어날 경우 확인을 안하고 pendingList.Clear해버리면 send패킷이 유실될 것 같습니다. BufferList에 넣으면 SendAsync시에 c#에서 무조건 전송을 보장해주는건가요? 아니면 BufferList를 사용하지 말고 recv버퍼처럼 해야할 것 같다는 생각이 들어 질문합니다. 또한 BufferList에서 부분전송 체크할 방법이 있나요?
C++과 다이렉트를 배우고 유니티를 배우기위해 학습하고있는 학생입니다 리소스 매니저에서 인스턴시에이트 시점에 각 오리지널 객체에대해 GetComponent함수를 통해 Poolable 객체의 보유여부를 판단하는 모습으로 보이는데요 C#과 유니티에 아직 미숙해서 문의를 남깁니다. GetComponent의 원리가 C++에서 각 컴포넌트를 일차원배열을 선형탐색하여 각각 폭포식으로 dynamic cast를 해보는것과 비슷한 수행성능을 낼 것으로 판단되는데 이게맞다면 모든객체의 인스턴스화 시점에 많은 오버헤드를 일으키지않나요? 만약 맞다면 풀 매니저에서 poolable을 지닌 객체와 안지닌 객체에대해 해시셋등의 자료구조를 통해 두가지의 경우를 캐싱을 하고 최초로 검사하는경우에만 GetComponent를 호출해서 맞는 컨테이너에 캐싱후 결과를 반환하는 식으로 하면 어떨까 질문드립니다. 예시로 만든 코드 남겨드립니다 .
강사님 Effect 에 추가적인 기능 구현에 대해 궁금한 점이 있어서 질문드립니다. 현재 강의의 Effect는 Start, Apply, Release의 세 가지 타이밍을 이용해서 여러 부가 효과를 주는 것으로 이해했습니다.(stat을 증가시키기, damage주기) 그런데 만약 죽음 저항, 마법 시전시 추가 피해, ,받는 화속성 피해 무효화, 특정 종족에게 가하는 피해 증가 등 다른 논리적인 코드 안에서 이 Effect의 여부를 따져야 하는 경우에는 어떤 식으로 처리할 수 있을까요? 예를 들어 죽음 저항의 Effect가 있다면 캐릭터의 TakeDamage의 코드 안에서 이 Effect의 여부를 따지는 부분이 필요할텐데 단순히 하드코딩으로 짜기엔 나중에 여러 효과들이 추가 되면 될 수록 감당할 수 없어질 것 같고 코드를 어떻게 확장 해야할지도 감이 잘 잡히지 않습니다. 제가 보기에도 질문이 조금 난해 하지만 결론은 이렇습니다. effect가 다른 많은 코드들에 영향을 주어야 할 경우 어떻게 안전하게 확장 할 수 있을까요?
우선 풍성한 내용의 강의에 항상 감사드립니다. 1.SelectedCard 함수가 CardSelector 에서는 유아이에서 선택 관련한 함수이고 Session Manager 에서는 데이터를 다루는 듯 한데요. 이름을 좀 다르게 쓰는게 낫지 않을까요. 아니면 크게 상관이 없는 건가요. 2.그리고 강의 전반에 걸쳐 Initalize 라고 쓰시는 거 같은데 Initialize 를 줄여서 임의로 쓰시는지도 궁금합니다. CardDB.cs 에서 CardDB 변수명을 db 로 간단히 사용하시는 부분은 차후에 다른 몬스터 db 나 혹은 게임이 확장되었을 시에 좀 혼란스럽지 않을까 하는데 강사님의 의견이 궁금합니다
안녕하세요 설명을 잘 해주셔서 몬스터 풀링 적용 했습니다 폰트 쪽에서 오류나는거 같은데 잘 모르겠습니다 ㅠㅠ 돌려 보면서 코드 비교 했는데 해결 하지못해서 질문합니다 Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues. UnityEngine.Transform:set_parent (UnityEngine.Transform) Object_Pool:Retrun (UnityEngine.GameObject,System.Action`1<UnityEngine.GameObject>) (at Assets/00_Scripts/Pool_Mng.cs:35) Pool_Mng:Add_Queue (string) (at Assets/00_Scripts/Pool_Mng.cs:90) Pool_Mng:Pooling_OBJ (string) (at Assets/00_Scripts/Pool_Mng.cs:67) Bullet:OnTriggerEnter (UnityEngine.Collider) (at Assets/00_Scripts/Bullet.cs:42)
루키스님 따라 공격범위 수정전에 Creature들의 범위가 현재 cell에서 어떻게 됐을지 근본적으로 궁금했었습니다. 기지모로 표현해보니까 이해가 잘 돼서 공유드립니다. 빨간 원이 CellPos이며 노란 원이 사자와 곰에 ExtraCells를 1씩 했었을 때 모습입니다.