인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

talentedwoo0898's profile image
talentedwoo0898

asked

Complete Guide to Unity Machine Learning Agents (Basics)

DroneSetting.cs 관련 질문

Written on

·

289

2

Drone 환경 만들때 

DroneSetting.cs 스크립트 작성 후 Area 에서 Add Component 에서 Drone Setting 컴포넌트를 추가하니

다음 화면처럼 Drone agent 와 Goal 메뉴가 보이지 않습니다. 

도와 주시면 감사 하겠습니다.

하기는 작성한 DroneSetting.cs 코드 입니다. 

 

 

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

public class DroneSetting : MonoBehaviour
{
    private GameObject DroneAgent;
    private GameObject Goal;

    private Vector3 areaInitPos;
    private Vector3 droneInitPos;
    private Quaternion droneInitRot;

    private Transform AreaTrans;
    private Transform DroneTrans;
    private Transform GoalTrans;

    private Rigidbody DroneAgent_Rigidbody;


    void Start()
    {
        AreaTrans = gameObject.transform;
        DroneTrans = DroneAgent.transform;
        GoalTrans = Goal.transform;

        areaInitPos = AreaTrans.position;
        droneInitPos = DroneTrans.position;
        droneInitRot = DroneTrans.rotation;

        DroneAgent_Rigidbody = DroneAgent.GetComponent<Rigidbody>();

    }

    public void AreaSetting()
    {
        DroneAgent_Rigidbody.velocity = Vector3.zero;
        DroneAgent_Rigidbody.angularVelocity = Vector3.zero;

        DroneTrans.position = droneInitPos;
        DroneTrans.rotation = droneInitRot;

        GoalTrans.position = areaInitPos + new Vector3(Random.Range(-5f, 5f), Random.Range(-5f, 5f), Random.Range(-5f, 5f));
        
    }

}

 

강화학습unity머신러닝 배워볼래요? unity-ml-agents

Answer 2

3

talentedwoo0898님의 프로필 이미지
talentedwoo0898
Questioner

아  두 변수를 public 으로 선언하니 됩니다! 감사합니다! 

강의에는 private 로 되어 있는데 수정이 필요해 보이네요.. 

도와주셔서 감사합니다. 

1

kyushik님의 프로필 이미지
kyushik
Instructor

안녕하세요! DroneAgent나 Goal과 같은 GameObject가 인스펙터 윈도우에 외부적으로 나타나게 설정하려면 private이 아니라 public으로 설정해주셔야 합니다. 이에 따라 DroneAgent와 Goal에 대한 코드를 

public GameObject DroneAgent

public GameObject Goal

이렇게 수정하고 다시 한번 확인해주시면 될 듯 합니다! :) 

talentedwoo0898's profile image
talentedwoo0898

asked

Ask a question