How to fix a "floaty" dice?

Godot Version

Godot 4.3

Question

I am trying to create dice physics in my game, and it is working pretty fine (needs adjustments on things like throwing) but my main concern right now is that the dice feel floaty and swings for a bit before stopping like if it was really heavy or had a big inertia (video for example)


(settings : dice = rigidbody, mass = 0.001 kg / friction = 0.9 / Bounce = 0 / Gravity scale = 1; friction = 1 on the ground=staticbody)

I would like my dice to feel more realistic/snappy and quickly stop on the ground after hitting it and rolling, but I can’t find how. I tried tweaking the bounciness and friction of the dice/ground, the mass and gravity scale on the dice, but it doesn’t really change the end result.

Here is the code for the dice launch if you want (I don’t thik it is relevant to the problem but why not)

func roll_to_tile(tile : ResTileData):
	var rayon = randf_range(0.1,0.3)
	var angle_0 = randf_range(0,2*PI)
	var start_position = Vector3(cos(angle_0),0,sin(angle_0)).normalized()*rayon
	global_position = tile.world_position + start_position
	
	#reset state
	sleeping = false
	freeze = false
	position = global_position + Vector3(0,0.8,0)
	linear_velocity = Vector3.ZERO
	angular_velocity = Vector3(randf_range(0,5),randf_range(0,5),randf_range(0,5))
	
	#random rotation
	transform.basis = Basis(Vector3.RIGHT, randf_range(0,2*PI))*transform.basis
	transform.basis = Basis(Vector3.UP, randf_range(0,2*PI))*transform.basis
	transform.basis = Basis(Vector3.FORWARD, randf_range(0,2*PI))*transform.basis
	var center_vector = Vector3(Vector3(randf_range(0,2*PI),0,randf_range(0,2*PI))).normalized()*1
	#random throw impulse
	var impulse_origin = Vector3(cos(angle_0),0,sin(angle_0))*0.2
	apply_central_impulse(center_vector*roll_strentgh)
	await get_tree().create_timer(0.01).timeout
	is_rolling = true
	show()

What should I try to fix this ?

try using jolt physics, the godot physics engine is not very stable, it’s good enough for simple games, but for something that needs more precise physics it is best to switch to jolt.

1 Like

I like the look of your game!

I have to be honest, if I was in your situation, I would probably just add some code to have the code wait for a couple of seconds after rolling, and then set the gravity scale really high. I find in game dev, the more realistic solution doesn’t always play well on the screen, y’know?

Thank you, I just tried jolt physics and it seems to really fix it ! I still have to tweak things a bit to have a satisfying dice roll but it is way better that way !

1 Like