0
Answered

Collisions in unity not working correctly

Bo Adam 2 years ago updated 1 year ago 18

Hello,

Sorry that I ask this question here, but I've tried everything and nothing works.

I am working with a carrier on a transport surface that has walls on both sides. I link multiple of these transport surfaces end to end (with a tiny air gap) and make the carrier move in a straight line. 

But after a few conveyors, my carrier rotates around Z and is stuck.

When I look up close, I can see that my carrier clipped through the wall. Both have box colliders and are set to continuous dynamic collision detection. The corners of my carrier have a cylinder with a convex mesh collider attached. 

You can see my picture below, I hope it is clear, but it is a top down view of my carrier clipping though the wall. (You can see the collider of the wall and carrier highlighted in green.

Image 683

I really hope you can help me! 

with kind regards,

Bo

Answer

Answer

Hi Bo,

you can try and set the collider of the turn table slightly lower than the conveyor before. Also I would suggest to close unity and delete the library folder within assets. This folder will be created by unity when you open your project again. Start your project again to check wether the problem still occurs.

A last option could be to use the contraints of the rigidbody of your moving object and freeze the z-axis.

Under review

Hi Bo, based on your picture it is not totally clear to me. In general physics and colliders is not always behaving like reality so very often some simply dummy colliders (best for performance is box colliders) are needed.

Hello, Thank you for your reply. 

I Have made box colliders and dummy colliders to make the process happen better.

I have attached a test scene, which you can find below. As soon as the carrier encounters the rotation station (in other parts of our main scene this happens with the push station as well) you can see that the carrier turns and becomes stuck. I don't know why this happens.


I've disabled the box colliders for the top lip of the rotation station, if you enable them (they are under the "name" game object) you get that the carrier starts clipping and jumping.

Thank you for helping me.


Bo

I cannot upload the file since it is 300mb, but i cant find the data transfer link anymore... Could you send it to me?

Hello Bo,

I have recieved the upload but there is no failure when I start the game mode. Can you check upon this?

I've send a video where you can see what happens when i play the test scene.

Collision bug 2.mkv

Collision bug 3.mkv

You can see here that it turns when going from one unit to another (i dont even know why?) and then clips into the wall launching it upward.

If it just goes straight there would be no problem i think.
Answer

Hi Bo,

you can try and set the collider of the turn table slightly lower than the conveyor before. Also I would suggest to close unity and delete the library folder within assets. This folder will be created by unity when you open your project again. Start your project again to check wether the problem still occurs.

A last option could be to use the contraints of the rigidbody of your moving object and freeze the z-axis.

To be honest, for such transport systems simple conveyor with physics is not enough. For stable behavior rigidbody must have only one degrees of freedom. The axis of degrees of freedom must be adjusted with movement direction of the conveyor. Here are some examples:vid
vid

Could you give a little more info on this script? It looks like your video's work perfectly, but i can't understand what this script does exactly (and how it works) by just reading the code.

Thanks!

The idea is the following.

Each part and each conveyor has a GuidedEntity and transport script, respectively.

OnCollisionEnter and OnCollisionExit are stored collided conveyors.

In the Update method, Raycast is used cyclically to check which conveyor the part is currently colliding with and to set the speed and position of the articulated anchors. If the part collides with several conveyors at the same time, I take the closest one.

If no collision happens or Conveyor type is wrong, then Joint is destroyed and the physical properties of the part are reset.

So i would have to add this script to my  mu's to make it work? Do you happen to have an example scene i can use for reference? From the video's it looks like it might be what i need, if it works with a rotating transport surface as well.

Difficult to say.

I don't have this package. But I'm sure it's not that much effort to implement the same principle with package classes.

I will try to contribute to https://github.com/game4automation this week then.

Answered

Just try the constraints of the rigidbody. This are just a few clicks before you redevelop the complete movement. You only need the rotation around y the rest could be freeze.

Thanks, I was planning on trying that first! I have moved the transport surface of the pusher down by 0,002 and now the error doesn't happen anymore. Just to be sure i've also locked rotation in the x and z direction. When it is in a gripper, does this lock also apply? else I will get a problem in my warehouse.

HI Bo, Hi Prely, complex transports with collissions are reaching the limits of Unity Physics. @Prely, thanks for the proposel, I will need to look deeper in it on the next days.

Specialy what we see in the video is only going to work with special coding. Pure Unity Physics are to limited here. So the standard conveyor in realvirtual is only a good solution it the transport direction is not very guided by some side guides and walls.

For the simulation library we implemented some special things like path based movements or the alignement on conveyors on entry. But for sure we will look into Prelys approach and think about, how  and if we could integrate it into standard.

What happens is that it rotates around the y axis when transferring from 1 transport surface to the other and becomes stuck. Also, the freeze rotation will uncheck after a little bit of transporting.