Exemplo n.º 1
0
    public void SetupAgent(CmvAgMan cmvAgMan)
    {
        Debug.Log($"  SetupAgent for {name}");
        this.cmvAgMan = cmvAgMan;
        SetupAgentSpaceType(SpaceType.Continuous);
        //LazyInitialize();// gets called when component is added in OnEnable

        area    = cmvAgMan.area;
        ground  = cmvAgMan.ground;
        redGoal = cmvAgMan.redGoal;
        //useVectorObs = true;

        // Create body
        avatar                  = GameObject.CreatePrimitive(PrimitiveType.Capsule);
        avatar.name             = "body";
        avatar.transform.parent = transform;
        cmvagbod                = avatar.AddComponent <CmvAgentBody>();
        var visor = GameObject.CreatePrimitive(PrimitiveType.Cube);
        var clder = visor.GetComponent <Collider>();

        clder.enabled              = false;
        visor.transform.parent     = avatar.transform;
        visor.transform.localScale = new Vector3(0.95f, 0.25f, 0.5f);
        visor.transform.position   = new Vector3(0, 0.5f, -0.25f);
        CmvAgentBody.SetColorOfGo(visor, Color.black);
        maxStep = cmvAgMan.cmvSettings.maxstep;

        cmvagbod.Init(this);

        groundRenderer = ground.GetComponent <Renderer>();
        groundMaterial = groundRenderer.material;
        cmvagbod.InitializeAgentBody();
    }
Exemplo n.º 2
0
    public void SetupAgent(CmvAgMan cmvAgMan)
    {
        this.cmvAgMan = cmvAgMan;

        // Initialize agent parameters
        //brain = cmvAgMan.brain;
        area            = cmvAgMan.area;
        ground          = cmvAgMan.ground;
        redGoal         = cmvAgMan.redGoal;
        agentParameters = cmvAgMan.agentParameters;

        useVectorObs = true;

        // Create body
        avatar                  = GameObject.CreatePrimitive(PrimitiveType.Capsule);
        avatar.name             = "body";
        avatar.transform.parent = transform;
        cmvagbod                = avatar.AddComponent <CmvAgentBody>();
        var visor = GameObject.CreatePrimitive(PrimitiveType.Cube);
        var clder = visor.GetComponent <Collider>();

        clder.enabled              = false;
        visor.transform.parent     = avatar.transform;
        visor.transform.localScale = new Vector3(0.95f, 0.25f, 0.5f);
        visor.transform.position   = new Vector3(0, 0.5f, -0.25f);
        CmvAgentBody.SetColorOfGo(visor, Color.black);

        cmvagbod.Init(this);
        //var bhp = GetComponent<BehaviorParameters>();
        //bhp.m_BehaviorName = "CrowdMove";
        ////bhp.m_UseHeuristic = true;
        //var bp = bhp.brainParameters;
        //bp.vectorActionSpaceType = SpaceType.Continuous;
        //bp.vectorObservationSize = 36;
        //bp.vectorActionSize = new int[] { 2 };
        //bp.vectorActionDescriptions = new string[] { "action1", "action2" };
        //this.sType = bp.vectorActionSpaceType;

        //SetupAgentSpaceType(SpaceType.Continuous);


        // Create banner textmeshpro
        //var text = name + "\n" + name;
        ////bannertmp = GraphAlgos.GraphUtil.MakeTextGo(gameObject, text, 1.5f, fvek: Vector3.back);
        //bannergo = bannertmp.transform.parent.gameObject;
        //bannergo.name = "banner";

        groundRenderer = ground.GetComponent <Renderer>();
        groundMaterial = groundRenderer.material;
        cmvagbod.InitializeAgentBody();
    }