How to get my dice to be less bouncy?

Godot Version

v4.1.1 Win64

Question

Hey there! i’m kinda new to gamedev and i’m trying to make a 3d dice roller for my crpg. I programmed a rolling system using a rigidbody, and made a little box for my die to roll in (4 collision shapes) but my problem is that my die rolls and bounces far too much! how do i make it less bouncy/rolly?

If you have a gravity property for that object, I guess you should increase that.
If you don’t, then I would recommend adding it.

It does depend on the rolling system… so unless you share some code, all we can do is guess.

1 Like

I tried increasing the mass of my rigidbody, it did not seem to work (or do anything, for the record)!
if i decrease the force of my dice throw, which is controlled by the variable “roll_strength”, the dice will still go to the wall and bounce a bunch, only much slower, if the gravity (the gravity slider on the Rigidbody) is increased, the dice wobbles indefinitely

here’s an example of what the die rolling looks like

extends RigidBody3D
var clicked = false
var overDie = false
var body = RigidBody3D
var start_pos
var roll_strength = 5

func _ready() -> void:
	connect("mouse_entered", whatever)
	connect("mouse_exited", whatever2)

func whatever2():
	overDie = false
func whatever():
	overDie = true

func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
			clicked = true
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed == false:
			clicked = false
	var mouse_pos = get_viewport().get_mouse_position()
	if overDie:
		if clicked:
			print("rolled die")
			_roll()


func _roll():
	sleeping = false
	freeze = false
	linear_velocity = Vector3.ZERO
	angular_velocity = Vector3.ZERO
	
	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 throw_vector = Vector3(randf_range(-1, 1), 0, randf_range(-1, 1)).normalized()
	angular_velocity = throw_vector * roll_strength /2
	apply_central_impulse(throw_vector * roll_strength)
 

try add physics material to dice and floor

Didn’t seem to work, the dice still rolls into infinity

Did a short google search, and it seems you are following this tutorial:

It is important to mention this in your question…
It does help us a lot.

Just by looking at this I can tell that my first answer is not a good one.

I have to look more into this.
The physics material has a “bounce” property, playing with that may give you an answer.

I do not have the time to look more into this atm, will be back with an answer in a few days if that is not too late.

1 Like

I did a quick tests using the same code you have provided.

I could not reproduce the error from your video.

There is nothing wrong with this code:

    sleeping = false
	freeze = false
	linear_velocity = Vector3.ZERO
	angular_velocity = Vector3.ZERO
	
	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 throw_vector = Vector3(randf_range(-1, 1), 0, randf_range(-1, 1)).normalized()
	angular_velocity = throw_vector * roll_strength /2
	apply_central_impulse(throw_vector * roll_strength)

Try commenting this code:

func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
			clicked = true
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed == false:
			clicked = false
	var mouse_pos = get_viewport().get_mouse_position()
	if overDie:
		if clicked:
			print("rolled die")
			_roll()

Then add a button with an event that rolls the die. See if the error still happens then.

image
image
in relation to what Moreus said

i have toyed around with the PhysicsMaterial of the dice, and nothing seems to work, could it be the shape of the die ?

what shape is it?, and if it this help
image
as it might help you and us understand what is going on with the collisions

Also, if you were wondering what i WANT the dice roller to be like, i’m basically trying to make a copy of the Owlbear Rodeo dice roller:

Here’s the die with no mesh, and with Visible Collision shapes
https://youtu.be/HjuFJ1rzlVw?si=wehWZnZA8Q26X2qX

The shape is a Rhombic d12, also known as a Rhombic Dodecahedron

HEY ALL! thought i’d give an update, i found out how to stop the dice from rolling/bouncing: using JOLT physics !

2 Likes