Ejemplo n.º 1
0
        public override void InitializeAgent()
        {
            Debug.Log($"Initialising agent in: {GetComponentInParent<Transform>().name}");
            Debug.Log($"Current brain: {brain}");
            base.InitializeAgent();
            decisionCounter = 0;
            _limbsTransform = new List <Transform>();
            _limbsBodyParts = new List <AnhaBodyPart>();

            _agentRb        = Root.GetComponent <Rigidbody>();
            _areaBounds     = Floor.GetComponent <Collider>().bounds;
            _groundRenderer = Floor.GetComponent <Renderer>();
            _groundMaterial = _groundRenderer.material;

            _targets = TargetsContainer.GetComponentsInChildren <Transform>().Skip(1).ToList();

            // Automatically adding all the bones of limbs;
            // Each limb ought to end with a child object with tag "hand"
            _hands = Finder.ChildrenWithTag(LimbsContainer.transform, "hand");
            SetLimbs();

            // SETTING UP THE joints CONTROLLER
            _jdController = GetComponent <JointDriveController>();
            _jdController.SetupBodyPart(Root.transform);
            _limbsTransform.ForEach(bp => _jdController.SetupBodyPart(bp));

            SetDirectionToClosestTarget();
        }
 public void initBodyParts()
 {
     jdController.SetupBodyPart(initPart);
     foreach (var part in parts)
     {
         jdController.SetupBodyPart(part);
     }
 }
Ejemplo n.º 3
0
    Matrix4x4 m_TargetDirMatrix;           //Matrix used by agent as orientation reference

    public override void Initialize()
    {
        m_JdController    = GetComponent <JointDriveController>();
        m_DirToTarget     = target.position - bodySegment0.position;
        m_LookRotation    = Quaternion.LookRotation(m_DirToTarget);
        m_TargetDirMatrix = Matrix4x4.TRS(Vector3.zero, m_LookRotation, Vector3.one);

        //Setup each body part
        m_JdController.SetupBodyPart(bodySegment0);
        m_JdController.SetupBodyPart(bodySegment1);
        m_JdController.SetupBodyPart(bodySegment2);
        m_JdController.SetupBodyPart(bodySegment3);
    }
Ejemplo n.º 4
0
        public override void InitializeAgent()
        {
            for (int i = 0; i < _rigs.Length; i++)
            {
                _rigs[i].EvaluateStart();
                _rigs[i].Reset();
            }

            _jdController = GetComponent <JointDriveController>();
            _jdController.SetupBodyPart(_armBase.transform);
            _jdController.SetupBodyPart(_armLow.transform);
            _jdController.SetupBodyPart(_armHigh.transform);
            _jdController.SetupBodyPart(_armTop.transform);
            _jdController.SetupBodyPart(_armRotator.transform);
        }
Ejemplo n.º 5
0
    public override void Initialize()
    {
        SetAgentType();

        m_OrientationCube    = GetComponentInChildren <OrientationCubeController>();
        m_DirectionIndicator = GetComponentInChildren <DirectionIndicator>();
        m_JdController       = GetComponent <JointDriveController>();

        //Setup each body part
        m_JdController.SetupBodyPart(body);
        m_JdController.SetupBodyPart(leg0Upper);
        m_JdController.SetupBodyPart(leg0Lower);
        m_JdController.SetupBodyPart(leg1Upper);
        m_JdController.SetupBodyPart(leg1Lower);
    }
Ejemplo n.º 6
0
    private Vector3 m_StartingPos; //starting position of the agent

    public override void Initialize()
    {
        SpawnTarget(TargetPrefab, transform.position); //spawn target

        m_StartingPos        = bodySegment0.position;
        m_OrientationCube    = GetComponentInChildren <OrientationCubeController>();
        m_DirectionIndicator = GetComponentInChildren <DirectionIndicator>();
        m_JdController       = GetComponent <JointDriveController>();

        UpdateOrientationObjects();

        //Setup each body part
        m_JdController.SetupBodyPart(bodySegment0);
        m_JdController.SetupBodyPart(bodySegment1);
        m_JdController.SetupBodyPart(bodySegment2);
        m_JdController.SetupBodyPart(bodySegment3);
    }
Ejemplo n.º 7
0
    public override void Initialize()
    {
        Controller = GetComponent <JointDriveController>();

        for (int i = 0; i < Parts.Count; i++)
        {
            Controller.SetupBodyPart(Parts[i]);
        }
    }
Ejemplo n.º 8
0
    public override void InitializeAgent()
    {
        jdController        = GetComponent <JointDriveController>();
        currentDecisionStep = 1;

        //Setup each body part
        jdController.SetupBodyPart(body);
        jdController.SetupBodyPart(leg0Upper);
        jdController.SetupBodyPart(leg0Lower);
        jdController.SetupBodyPart(leg1Upper);
        jdController.SetupBodyPart(leg1Lower);
        jdController.SetupBodyPart(leg2Upper);
        jdController.SetupBodyPart(leg2Lower);
        jdController.SetupBodyPart(leg3Upper);
        jdController.SetupBodyPart(leg3Lower);
    }
Ejemplo n.º 9
0
    Matrix4x4 m_TargetDirMatrix;           //Matrix used by agent as orientation reference

    public override void Initialize()
    {
        m_JdController    = GetComponent <JointDriveController>();
        m_DirToTarget     = target.position - bodySegment0.position;
        m_LookRotation    = Quaternion.LookRotation(m_DirToTarget);
        m_TargetDirMatrix = Matrix4x4.TRS(Vector3.zero, m_LookRotation, Vector3.one);

        //Setup each body part
        m_JdController.SetupBodyPart(bodySegment0);
        m_JdController.SetupBodyPart(bodySegment1);
        m_JdController.SetupBodyPart(bodySegment2);
        m_JdController.SetupBodyPart(bodySegment3);

        //We only want the head to detect the target
        //So we need to remove TargetContact from everything else
        //This is a temp fix till we can redesign
        DestroyImmediate(bodySegment1.GetComponent <TargetContact>());
        DestroyImmediate(bodySegment2.GetComponent <TargetContact>());
        DestroyImmediate(bodySegment3.GetComponent <TargetContact>());
    }
Ejemplo n.º 10
0
    public override void InitializeAgent()
    {
        m_JdController = GetComponent <JointDriveController>();
        m_DirToTarget  = target.position - body.position;


        //Setup each body part
        m_JdController.SetupBodyPart(body);
        m_JdController.SetupBodyPart(leg0Upper);
        m_JdController.SetupBodyPart(leg0Lower);
        m_JdController.SetupBodyPart(leg1Upper);
        m_JdController.SetupBodyPart(leg1Lower);
        m_JdController.SetupBodyPart(leg2Upper);
        m_JdController.SetupBodyPart(leg2Lower);
        m_JdController.SetupBodyPart(leg3Upper);
        m_JdController.SetupBodyPart(leg3Lower);
    }
Ejemplo n.º 11
0
    public override void Initialize()
    {
        orientationCube.UpdateOrientation(body, target.transform);

        m_JdController = GetComponent <JointDriveController>();

        //Setup each body part
        m_JdController.SetupBodyPart(body);
        m_JdController.SetupBodyPart(leg0Upper);
        m_JdController.SetupBodyPart(leg0Lower);
        m_JdController.SetupBodyPart(leg1Upper);
        m_JdController.SetupBodyPart(leg1Lower);
        m_JdController.SetupBodyPart(leg2Upper);
        m_JdController.SetupBodyPart(leg2Lower);
        m_JdController.SetupBodyPart(leg3Upper);
        m_JdController.SetupBodyPart(leg3Lower);
    }
Ejemplo n.º 12
0
    public override void Initialize()
    {
        SpawnTarget(dynamicTargetPrefab, transform.position);
        m_OrientationCube = GetComponentInChildren <OrientationCubeController>();
        //m_DirectionIndicator = GetComponentInChildren<DirectionIndicator>();
        m_JdController = GetComponent <JointDriveController>();

        //Setup each body part
        m_JdController.SetupBodyPart(body);
        m_JdController.SetupBodyPart(leg0Upper);
        m_JdController.SetupBodyPart(leg0Lower);
        m_JdController.SetupBodyPart(leg1Upper);
        m_JdController.SetupBodyPart(leg1Lower);
        m_JdController.SetupBodyPart(leg2Upper);
        m_JdController.SetupBodyPart(leg2Lower);
        m_JdController.SetupBodyPart(leg3Upper);
        m_JdController.SetupBodyPart(leg3Lower);
    }
Ejemplo n.º 13
0
    public override void InitializeAgent()
    {
        base.InitializeAgent();

        bodyrb = body.GetComponent <Rigidbody>();

        startPos = transform.position;
        startRot = transform.rotation;

        jointControl = GetComponent <JointDriveController>();

        //Setup the body parts in the joint controller
        jointControl.SetupBodyPart(body);

        for (int i = 0; i < 8; i++)
        {
            jointControl.SetupBodyPart(upperJoints[i]);
        }

        for (int i = 0; i < 8; i++)
        {
            jointControl.SetupBodyPart(lowerJoints[i]);
        }
    }
Ejemplo n.º 14
0
    void Awake()
    {
        // Audio Setup
        audioSourceSFX = body.gameObject.AddComponent <AudioSource>();
        audioSourceSFX.spatialBlend = .75f;
        audioSourceSFX.minDistance  = .7f;
        audioSourceSFX.maxDistance  = 5;
        if (canBark)
        {
            StartCoroutine(BarkBarkGame());
        }

        //Joint Drive Setup
        jdController = GetComponent <JointDriveController>();
        jdController.SetupBodyPart(body);
        jdController.SetupBodyPart(leg0_upper);
        jdController.SetupBodyPart(leg0_lower);
        jdController.SetupBodyPart(leg1_upper);
        jdController.SetupBodyPart(leg1_lower);
        jdController.SetupBodyPart(leg2_upper);
        jdController.SetupBodyPart(leg2_lower);
        jdController.SetupBodyPart(leg3_upper);
        jdController.SetupBodyPart(leg3_lower);
    }
Ejemplo n.º 15
0
    public override void Initialize()
    {
        action1 = -1f;
        action2 = -1f;
        action3 = -1f;
        action4 = -1f;

        pose0Time = Time.time + 10000;
        pose1Time = Time.time + 10000;
        pose2Time = Time.time + 10000;
        pose3Time = Time.time + 10000;
        pose4Time = Time.time + 10000;
        curangle  = 0.0f;
        curGrip   = 1f;
        gobj      = Instantiate(tc.gameObject, transform);
        //gobj.GetComponent<TargetController>().m_startingPos = transform.position;

        m_JdController = GetComponent <JointDriveController>();

        //Setup each body part
        m_JdController.SetupBodyPart(arm_base);
        m_JdController.SetupBodyPart(turner);
        m_JdController.SetupBodyPart(bone1);
        m_JdController.SetupBodyPart(bone2);
        m_JdController.SetupBodyPart(bone3);
        m_JdController.SetupBodyPart(hand);/*
                                            * m_JdController.SetupBodyPart(finger1);
                                            * m_JdController.SetupBodyPart(phalanx1);
                                            * m_JdController.SetupBodyPart(forePhalanx1);
                                            * m_JdController.SetupBodyPart(finger2);
                                            * m_JdController.SetupBodyPart(phalanx2);
                                            * m_JdController.SetupBodyPart(forePhalanx2);
                                            * m_JdController.SetupBodyPart(finger3);
                                            * m_JdController.SetupBodyPart(phalanx3);
                                            * m_JdController.SetupBodyPart(forePhalanx3);
                                            * m_JdController.SetupBodyPart(finger4);
                                            * m_JdController.SetupBodyPart(phalanx4);
                                            * m_JdController.SetupBodyPart(forePhalanx4);*/
    }
Ejemplo n.º 16
0
    public override void InitializeAgent()
    {
        m_JdController = GetComponent <JointDriveController>();
        m_JdController.SetupBodyPart(hips);
        m_JdController.SetupBodyPart(chest);
        m_JdController.SetupBodyPart(spine);
        m_JdController.SetupBodyPart(head);
        m_JdController.SetupBodyPart(thighL);
        m_JdController.SetupBodyPart(shinL);
        m_JdController.SetupBodyPart(footL);
        m_JdController.SetupBodyPart(thighR);
        m_JdController.SetupBodyPart(shinR);
        m_JdController.SetupBodyPart(footR);
        m_JdController.SetupBodyPart(armL);
        m_JdController.SetupBodyPart(forearmL);
        m_JdController.SetupBodyPart(handL);
        m_JdController.SetupBodyPart(armR);
        m_JdController.SetupBodyPart(forearmR);
        m_JdController.SetupBodyPart(handR);

        m_HipsRb  = hips.GetComponent <Rigidbody>();
        m_ChestRb = chest.GetComponent <Rigidbody>();
        m_SpineRb = spine.GetComponent <Rigidbody>();

        var academy = FindObjectOfType <WalkerAcademy>();

        m_ResetParams = academy.resetParameters;

        SetResetParameters();
    }
Ejemplo n.º 17
0
 public override void InitializeAgent()
 {
     jdController = GetComponent <JointDriveController>();
     jdController.SetupBodyPart(hips);
     jdController.SetupBodyPart(chest);
     jdController.SetupBodyPart(spine);
     jdController.SetupBodyPart(head);
     jdController.SetupBodyPart(thighL);
     jdController.SetupBodyPart(shinL);
     jdController.SetupBodyPart(footL);
     jdController.SetupBodyPart(thighR);
     jdController.SetupBodyPart(shinR);
     jdController.SetupBodyPart(footR);
     jdController.SetupBodyPart(armL);
     jdController.SetupBodyPart(forearmL);
     jdController.SetupBodyPart(handL);
     jdController.SetupBodyPart(armR);
     jdController.SetupBodyPart(forearmR);
     jdController.SetupBodyPart(handR);
 }
Ejemplo n.º 18
0
    public override void Initialize()
    {
        orientationCube.UpdateOrientation(hips, target.transform);

        //Setup each body part
        m_JdController = GetComponent <JointDriveController>();
        m_JdController.SetupBodyPart(hips);
        m_JdController.SetupBodyPart(chest);
        m_JdController.SetupBodyPart(spine);
        m_JdController.SetupBodyPart(head);
        m_JdController.SetupBodyPart(thighL);
        m_JdController.SetupBodyPart(shinL);
        m_JdController.SetupBodyPart(footL);
        m_JdController.SetupBodyPart(thighR);
        m_JdController.SetupBodyPart(shinR);
        m_JdController.SetupBodyPart(footR);
        m_JdController.SetupBodyPart(armL);
        m_JdController.SetupBodyPart(forearmL);
        m_JdController.SetupBodyPart(handL);
        m_JdController.SetupBodyPart(armR);
        m_JdController.SetupBodyPart(forearmR);
        m_JdController.SetupBodyPart(handR);

        m_ResetParams = Academy.Instance.EnvironmentParameters;

        SetResetParameters();
    }
Ejemplo n.º 19
0
    public override void InitializeAgent()
    {
        jdController = GetComponent <JointDriveController>();
        jdController.SetupBodyPart(hips);
        jdController.SetupBodyPart(chest);
        jdController.SetupBodyPart(spine);
        jdController.SetupBodyPart(head);
        jdController.SetupBodyPart(thighL);
        jdController.SetupBodyPart(shinL);
        jdController.SetupBodyPart(footL);
        jdController.SetupBodyPart(thighR);
        jdController.SetupBodyPart(shinR);
        jdController.SetupBodyPart(footR);
        jdController.SetupBodyPart(armL);
        jdController.SetupBodyPart(forearmL);
        jdController.SetupBodyPart(handL);
        jdController.SetupBodyPart(armR);
        jdController.SetupBodyPart(forearmR);
        jdController.SetupBodyPart(handR);

        SaveState();

        parentPos      = this.transform.position;
        parentRotation = this.transform.rotation;
    }
Ejemplo n.º 20
0
    public override void InitializeAgent()
    {
        m_JdController = GetComponent <JointDriveController>();
        m_JdController.SetupBodyPart(hips);
        m_JdController.SetupBodyPart(chest);
        m_JdController.SetupBodyPart(spine);
        m_JdController.SetupBodyPart(head);
        m_JdController.SetupBodyPart(thighL);
        m_JdController.SetupBodyPart(shinL);
        m_JdController.SetupBodyPart(footL);
        m_JdController.SetupBodyPart(thighR);
        m_JdController.SetupBodyPart(shinR);
        m_JdController.SetupBodyPart(footR);
        m_JdController.SetupBodyPart(armL);
        m_JdController.SetupBodyPart(forearmL);
        m_JdController.SetupBodyPart(handL);
        m_JdController.SetupBodyPart(armR);
        m_JdController.SetupBodyPart(forearmR);
        m_JdController.SetupBodyPart(handR);

        m_HipsRb  = hips.GetComponent <Rigidbody>();
        m_ChestRb = chest.GetComponent <Rigidbody>();
        m_SpineRb = spine.GetComponent <Rigidbody>();

        m_ResetParams = Academy.Instance.FloatProperties;

        SetResetParameters();
    }
Ejemplo n.º 21
0
    public override void Initialize()
    {
        m_OrientationCube    = GetComponentInChildren <OrientationCubeController>();
        m_DirectionIndicator = GetComponentInChildren <DirectionIndicator>();

        //Setup each body part
        m_JdController = GetComponent <JointDriveController>();
        m_JdController.SetupBodyPart(hips);
        m_JdController.SetupBodyPart(chest);
        m_JdController.SetupBodyPart(spine);
        m_JdController.SetupBodyPart(head);
        m_JdController.SetupBodyPart(thighL);
        m_JdController.SetupBodyPart(shinL);
        m_JdController.SetupBodyPart(footL);
        m_JdController.SetupBodyPart(thighR);
        m_JdController.SetupBodyPart(shinR);
        m_JdController.SetupBodyPart(footR);
        m_JdController.SetupBodyPart(armL);
        m_JdController.SetupBodyPart(forearmL);
        m_JdController.SetupBodyPart(handL);
        m_JdController.SetupBodyPart(armR);
        m_JdController.SetupBodyPart(forearmR);
        m_JdController.SetupBodyPart(handR);

        m_ResetParams = Academy.Instance.EnvironmentParameters;

        SetResetParameters();
    }