#CharacterBody gravity vs RigidBody gravity

1 messages · Page 1 of 1 (latest)

daring galleon
#

Version: v4.6.2.rc1.official [257ac3532]

Question:

This simple code for gravity:

func _physics_process(delta: float) -> void:
    if not is_on_floor():
        velocity += get_gravity() * delta

    move_and_slide()

And without other external forces, I assume that the acceleration due to gravity should be the same for CharacterBody and the RigidBody, but the result looks different:

  • In both 2D and 3D, CharacterBody and Rigdbody show different results.
  • In 3D, I tested Jolt and GodotPhysics, and both showed the same behavior.

I’m using default settings, without any adjustments.

They should both fall at the same time, or have I misunderstood the behavior of gravity?

normal aspen
#

Just want to comment that your code for gravity looks correct to me. Gravity is the rate of change of velocity over time, so you are using it correctly to update velocity each physics frame. And multiplying by delta in this case is correct

#

As far as why it doesn't match up to the behavior of a rigid body, I don't know the answer

distant hill
#

rigidbodies have drag by default, no? that could be it