Jolt Physics causing insane CharacterBody3D and RigidBody3d launch upon collision

Godot Version

4.6.1

Question

After finishing my FPS movement, I decided to add a basic RigidBody3D, however with Jolt Physics, this happens when CharacterBody3D collides with RigidBody3D, I'm not sure how to prevent this behaviour, also Godot Physics has the same problem but less frequent. How do I fix this?

At least for me, I don’t understand the issue by just looking the video.

What’s the issue?
What do you expect to happen?
What did happen?
What exactly trigger the issue? (steps to replicate the issue)

Any additional info would help people to help you.


Here’s a longer video

The issue is the CharacterBody3D if moving too fast off the RigidBody3D gets launched off by the RigidBody3D and the RigidBody3D gets launched off by the CharacterBody3D

I expect the physics to collide normally, can’t push because there’s no programmed logic for that but can collide

What happened is that the CharacterBody3D if moving too fast off the RigidBody3D gets launched off by the RigidBody3D and the RigidBody3D gets launched off by the CharacterBody3D

What triggers the issue:
Set the physics engine into Jolt Physics (yes, It’s not the default for me somehow.)
Setup a basic Gridmap
Setup a basic RigidBody3D
Setup CharacterBody3D with this script

extends CharacterBody3D

const SPEED = 5.0
const JUMP_VELOCITY = 4.5
const acceleration = 0.3
const sens = 0.003

@onready var camera = $Camera3D

func \_ready() → void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

func \_unhandled_input(event: InputEvent) → void:
if event is InputEventMouseMotion:
rotate_y(-event.relative.x \* sens)
camera.rotate_x(-event.relative.y \* sens)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))

func \_physics_process(delta: float) → void:


if not is_on_floor():
	velocity += get_gravity() * delta

if Input.is_action_just_pressed("ui_accept") and is_on_floor():
	velocity.y = JUMP_VELOCITY

var input_dir := Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_on_floor():
	if direction:
		velocity = velocity.move_toward( Vector3(direction.x * SPEED, velocity.y, direction.z * SPEED), acceleration ) 
	else:
		velocity = velocity.move_toward( Vector3(0, velocity.y, 0), acceleration )
# $Camera3D/Label.text = str(ground_ray.get_collider(0))

move_and_slide()

Move the CharacterBody3D on top of the RigidBody3D

1 Like

I did a quick test using your code and it did moving too fast when jump on top of the rigidbody. I’m not sure myself but it might be logic in the code which repeatedly increase the velocity value through acceleration.

I’ll try more later.

Your CharacterBody3D believes the rigid body is a moving platform, as the rigidbody moves and rotates it will move and displace your character, using collision layers you can set the rigid body to a layer different from the character body’s moving platform layers.