Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in PhysicsServer3D bodies on kinematic mode between 4.3-dev4 and 4.3-dev5, bodies in kinematic mode act like static #97293

Closed
FireCatMagic opened this issue Sep 21, 2024 · 2 comments · Fixed by #97315

Comments

@FireCatMagic
Copy link

Tested versions

Does not work in 4.4-dev2, 4.3-stable, 4.3-beta1, 4.3-dev5

Works in 4.2.2-stable, 4.3-dev3, 4.3-dev4

System information

Godot v4.2.2.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4050 Laptop GPU (NVIDIA; 32.0.15.6070) - 13th Gen Intel(R) Core(TM) i5-13500HX (20 Threads)

Issue description

To start, let me show a working version of what is supposed to happen, in Godot 4.2.2-stable.
Godot_v4 2 2-stable_win64_SnL80UGxli
On the left, there is a RigidBody3D node riding atop of a kinematic body created by the PhysicsServer3D. On the left is the same thing except the rigidbody is a CharacterBody3D.

The moving platform is created with the following little script:

extends MeshInstance3D

var body: RID = PhysicsServer3D.body_create()

func _ready() -> void:
	PhysicsServer3D.body_set_space(body, get_world_3d().space)
	var shape: RID = PhysicsServer3D.box_shape_create()
	PhysicsServer3D.shape_set_data(shape, Vector3.ONE *0.5)
	PhysicsServer3D.body_add_shape(body, shape)
	PhysicsServer3D.body_set_mode(body, PhysicsServer3D.BODY_MODE_KINEMATIC)
	
func _physics_process(delta: float) -> void:
	position.x = sin(Engine.get_physics_frames() * 0.01)
	PhysicsServer3D.body_set_state(body, PhysicsServer3D.BODY_STATE_TRANSFORM, global_transform)

This was behavior I used in my game - it allowed to have a ton of moving platforms without using the SceneTree.
When loaded in Godot 4.3-stable, instead it acts like the right body is a StaticBody to the characterbody, but for some reason still works on the RigidBody.
Setting the body mode to BODY_MODE_STATIC is now no different from BODY_MODE_KINEMATIC.
Godot_v4 3-stable_win64_SONnJUdvuB

I went and tested random 4.3 versions till I could find which one introduced this change.
4.3-beta1 - Does not work
4.3-dev3- Works
4.3-dev4 - Works
4.3-dev5 - Does not work

So it was a change inside of 4.3-dev5 that broke it, as it works inside 4.3-dev4 but not 4.3-dev5
Godot_v4 3-dev4_win64_dgCYKqlRDn
Here it is in 4.3-dev4, working as intended.

NOTE: Using a CharacterBody3D as a moving platform still works, but this is related to using the PhysicsServer3D to create these bodies.

Steps to reproduce

See above, creating moving platforms using PhysicsServer3D works in Godot 4.3-dev4 but not Godot 4.3-dev5.

Minimal reproduction project (MRP)

New Compressed (zipped) Folder.zip

@matheusmdx
Copy link
Contributor

Bisecting points to #88947 as the culprit, @lawnjelly

image

@lawnjelly
Copy link
Member

lawnjelly commented Sep 22, 2024

Am investigating, looks like _set_platform_data() is being called with a valid RID but the platform_id is 0 (unset), therefore the safety check fails.

UPDATE:
Got it, the collision is coming from a GodotCollisionObject3D which has a RID but is not derived from Object so is not in the ObjectDB. I'd assumed that the platform_ids were valid based on the MRP in the original issue (#74732) .

This might mean we can only perform lifetime checks on collision objects derived from Object. I'll have a look back at the original bug and see most appropriate way of fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants