- Home /
How to avoid frictionless surface in 2D collision?
Okay question looks a bit weird but its really easy actually. I am trying to make a simulation with 2D circles and one box. Each of them has collider and I would like to simulate each ball going random direction inside of the box. And If they hit the box, just collide and continue randomly going.
It looks to this when I start the simulation  Than this:
 Than this:  In the end all balls gather at the 4 corner but I am out of limit of my screenshots.
 In the end all balls gather at the 4 corner but I am out of limit of my screenshots.
My dot script is like this:
 public class humanAgent : MonoBehaviour
 {
     // Start is called before the first frame update
 
     private Rigidbody2D rb;
     public float speed = 1;
     private SpriteRenderer sr;
     public bool isInfected =false;
     public Vector2 randomVector;
     void Start()
     {
         sr = GetComponent<SpriteRenderer>();
         rb = GetComponent<Rigidbody2D>();
         randomVector = new Vector2(Random.Range(-1f,1f), Random.Range(-1f,1f));
         rb.velocity = randomVector * speed;
     }
 
     // Update is called once per frame
     void Update()
     {
 
         rb.velocity = speed * (rb.velocity.normalized);
 
         if (isInfected) getInfection();
     }
I tried to add physical material and played with friction / bounceness however didnt make any difference.
Answer by ahsen35813 · Apr 22, 2020 at 02:38 PM
That's a very strange issue. If your balls all have 2D Circle Colliders with at least some bounciness, there is no reason they should do that. I only encountered that issue when I had 0 friction and 0 bounciness.
Your answer
 
 
             Follow this Question
Related Questions
Physics.Simulate not working in Editor (or Play Mode) 0 Answers
Ball bounces at different heights when it shouldn't 0 Answers
Scaling down my model or scaling up the gravity 3 Answers
Collider detection with simulated sprite. 2D,How do I make simulated sprites collide? 2 Answers
Rigidbody slightly falls into boxcollider and gets pushed out 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                