Reputation: 31
The picture below is my simulation, and the problem im facing is that they wont collide they way i want to.
I made them move randomly and i want this behavior.
How do i do this. I have looked at multiple tutorials and i simply dont know what to do. As far as i understand, to make a collision, one of the objects has to have a rigidbody on, and the other a normal collider?
I have to tried to follow this overview. The balls are from the same prefab, so to get a trigger for them i have to pick either static trigger collider, rigidbody collider trigger, or kinematic rigidbody trigger collider (as seem from the overview). BUT if i pick any of those i cant get a collision with the walls? Do i have to do the wall collisions myself?
Upvotes: 1
Views: 573
Reputation: 180
What you can do is make all the walls static colliders, and make a script on all the balls that check whether they hit a wall or a ball. and do actions that way.
Or
Make the walls check for a collision with the ball and add a force to the negative direction that they came from or something.(up to you how you want the balls to behave)
for example :
OnTriggerEnter(collision other)
if(other.transform.tag == Ball)
//Run Some Code here
// for example
BallRb other.GetComponent<RigidBody>();
BalRb.addForce //add the force that you want.
Upvotes: 1