- Edited
Hello everyone,
I recently converted my project to Godot 4 and all went great, until I encountered this issue. The problem is that, when RigidBody enters an area with gravity space override, gets pulled to the middle (gravity point enabled), then its position is set to the outside of this area, it is then still attracted by the area's gravity no matter where it is located. In Godot 3, this worked well. I have tried various solutions and workarounds, that I could come up with, but unfortunately nothing seems to work. I made two sample projects (one in Godot 3 and the other in Godot 4) to showcase this behavior. I am not quite sure if this could be some bug in physics engine in Godot 4 or it is just me doing something wrong. Any help is greatly appreciated. Thank you very much.
Project settings:
Default gravity vector: 0,0,0
Default linear damp: 0
Default angular damp: 0
Godot 4 code:
extends Node3D
func _physics_process(delta):
if Input.is_action_just_pressed("ui_accept"):
get_node("RigidBody3D").apply_impulse(Vector3(0,0,-1) * 100)
func _on_center_area_body_entered(body):
body.freeze = true
_reset_body()
func _reset_body():
get_node("RigidBody3D").global_transform.origin = Vector3(0,0,60)
get_node("RigidBody3D").freeze = false
`
Godot 3 code:
`extends Spatial
func _physics_process(delta):
if Input.is_action_just_pressed("ui_accept"):
get_node("RigidBody").apply_impulse(Vector3(),Vector3(0,0,-1) * 40)
func _on_Center_area_body_entered(body):
body.mode = RigidBody.MODE_STATIC
_reset_body()
func _reset_body():
get_node("RigidBody").global_transform.origin = Vector3(0,0,60)
get_node("RigidBody").mode = RigidBody.MODE_RIGID