File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -56,8 +56,15 @@ bool CharacterBody3D::move_and_slide() {
5656 excluded = (platform_wall_layers & platform_layer) == 0 ;
5757 }
5858 if (!excluded) {
59- // this approach makes sure there is less delay between the actual body velocity and the one we saved
60- PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton ()->body_get_direct_state (platform_rid);
59+ PhysicsDirectBodyState3D *bs = nullptr ;
60+
61+ // We need to check the platform_rid object still exists before accessing.
62+ // A valid RID is no guarantee that the object has not been deleted.
63+ if (ObjectDB::get_instance (platform_object_id)) {
64+ // this approach makes sure there is less delay between the actual body velocity and the one we saved
65+ bs = PhysicsServer3D::get_singleton ()->body_get_direct_state (platform_rid);
66+ }
67+
6168 if (bs) {
6269 Vector3 local_position = gt.origin - bs->get_transform ().origin ;
6370 current_platform_velocity = bs->get_velocity_at_local_position (local_position);
You can’t perform that action at this time.
0 commit comments