Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Trying to simulate my first unity reinforcement learning algorithm

Discussion in 'Unity Simulation' started by HoodIsBack, Oct 8, 2020.

Thread Status:
Not open for further replies.
  1. HoodIsBack

    HoodIsBack

    Joined:
    Dec 21, 2015
    Posts:
    4
    Hello!
    I am trying to teach this red square to catch the green square, and at the same time teach the green square to escape the red square using reinforcement learning. (So basically playing tag)
    upload_2020-10-8_17-37-51.png

    For my learning phase i would like to simulate 100 games of tag going on at the same time in simulation.
    But i am unable to disable the colliders for the squares that spawn, this is how my code goes :
    Physics.IgnoreLayerCollision(8, 8, true); //Reds ignore Reds
    Physics.IgnoreLayerCollision(9, 9, true); //Greens ignore Greens
    Physics.IgnoreLayerCollision(8, 9, true); //Reds ignore Greens
    And after creating a duo of new instances of red & green i do :
    Physics.IgnoreCollision(NewPlayer.GetComponent<BoxCollider>(), NewEnemy.GetComponent<BoxCollider>(),false);
    to re-enable their collision with their single opponent.

    The problem i'm facing is that the collisions are not properly disabled at the start of simulation :
    upload_2020-10-8_17-42-55.png
    I'm guessing this is Unity not liking that i put 100 objects at the same place and pushing them away from each other?

    Is there a way to make the objects completely ignore each other as if i was running 100 separate ghost simulations?

    Thanks for taking some of your time reading this and i hope you can help me!

    EDIT : Also it doesnt seem that my attempt at re-enabling the collision with the single opponent does not overwrite the layer collision disabling, but this is a side problem because i expect the answer you will give me to my first problem to make me completely change how i go about collisions.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    8,164
  3. HoodIsBack

    HoodIsBack

    Joined:
    Dec 21, 2015
    Posts:
    4
    Thanks!
     
    JeffDUnity3D likes this.
Thread Status:
Not open for further replies.
unityunity