Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Trying to simulate my first unity reinforcement learning algorithm

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

Thread Status:
Not open for further replies.
  1. Deleted User

    Deleted User

    Guest

    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

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. Deleted User

    Deleted User

    Guest

    Thanks!
     
    JeffDUnity3D likes this.
Thread Status:
Not open for further replies.