How do I make the collision detection more precise? (Jolt physics, Coin pusher game)

Godot Version

4.2.1

Question

I’m a beginner with programming and Godot and I’m trying to make a coin pusher game in 3D and I got some basic stuff set up, but the physics collision detection seems very imprecise.

There are mainly 3 objects interacting.

  1. The floor, which is a StaticBody3D.
  2. The pusher, which is a RigidBody3D.
  3. The coins, which are also RigidBody3D’s.
    All of them have a MeshInstance3D and a CollisionShape3D as child nodes.

The pusher goes back and forth because of an AnimationPlayer, which animates the MeshInstance3D and CollisionShape3D.

Pusher problems
What I don’t understand, is that coins are going into the mesh of the pusher. When they lay flat, a tiny bit goes in the mesh. But when they are standing up, the pusher always pushes the face of the coin that is the farthest from the pusher. So as the viewer, you can only see a flat circle on the pusher, until it goes backwards and the full coin becomes visible again.
When there are about 5 coins or more, the pusher only pushes a few coins, while other disappear into the mesh of the pusher.

Coin problems
What I also don’t understand, is why the coins can’t even really get pushed across the ‘bridge’ part. They bunch up together, slide into each other and don’t really seem to move after a certain time or after a certain amount of coins.
The front coins don’t really react to coins being pushed in from behind.
When there are a lot, and I mean A LOT, of coins in play, then a coin or two might make it across. But I don’t want it to be that many. And I want the coins to respond better to being pushed around.

What I tried and didn’t (seem to) help
With the RigidBody3D’s I tried:

  • playing around with the roughness of the coins and pusher.
  • turning Can Sleep Off and On
  • turning Continuous Collision Detection On, under the Solver
  • turning Max Contacts up

Under Project Settings, under Physics, 3D, I tried:

  • turning up Solver Iterations

And under Project Settings, Physics, Jolt 3D, I tried:

  • turning off sleep
  • turning off Use Shape Margins
  • turning up Movement Threshold
  • turning down Max Penetration

Am I right in asking how I can make the collision detection more precise?
Or is there something else which can impact the response and reaction of the pusher and coins?

I have more screenshots, but as a new user I am only allowed one screenshot.

And these are close-ups:
screenshot_1

1 Like

I’m pretty sure you are not supposed to move RigidBody directly (which animation player does), and instead use forces/impulses or _integrate_forces() function.

Otherwise from Physics Server standpoint the pusher is just teleported every frame.

1 Like

Hello! It seems to me that you should not use MeshInstance3D and CollisionShape3D animation. Use joints to move a “pusher” object.

I can suggest you the following option: Create an adjacent Generic6DOFJoint and StaticBody3D (without collider). Set Node_A to your “pusher” and StaticBody3D to Node_B respectively. Animate the position of the StaticBody3D.

Also you can try using Linear Motor at joint.

Also you can try using

_integrate_forces()

But this may not give the desired effect.

Hello, thank you both for your response.

@Exerion Not supposed to move RigidBody makes a lot of sense, I didn’t know that. Although I still have to try the use of forces/impulses, but I don’t know how to do that yet, so I’m following a tutorial for that and then I will come back to this project.

@RAS I tried your suggested method of using a Generic6DOFJoint and Staticbody3D and animating the StaticBody3D. But it did not seem to make a difference. The ‘pusher’ would still slide into and over coins.
I can’t try your other solutions, because I simply don’t know how they work yet. :stuck_out_tongue: So I’ll have to learn more about Godot and then come back to this.

1 Like

This may be similar to what you were trying to do (I used the method with Generic6DOFJoint and StaticBody3D):

You may have used ConvexPolygonShape3D for your RigidBody3D. In this case, you should try using the built-in BoxShape3D.
Also I haven’t used Jolt.

This is what my scene looks like:

Let me know if you need a zip with this scene.

1 Like

Thank you for taking the time to test it out. I would like to get the zip file with that scene, so I could check it out.

1 Like

Use space to run pusher. Also pay attention to the collision layers.

ZIP

1 Like