RigidBody2D after setting it to MODE_STATIC behaves like RigidBody after collision with KinematickBody2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By atmeo

So, I am trying to make RigidBody2D behave like StaticBody after some event. For this purpose I use this code:

extends RigidBody2D

func _on_Bullet_body_entered(_body: Node) -> void:
  sleeping = true
  mode = MODE_STATIC

The problem happens when KinematicBody2D collides that node. It starts to behave like RigidBody2D again.

But if I set mode using godot interface it works perfectly, exactly how I need.

What am I doing wrong?

The left ball set static by code, the right one set static from interface
footage

Also, the engine thinks that the object is static:
interface

What is MODE_STATIC? Is it a variable you defined yourself? Can you try using RigidBody2D.MODE_STATIC instead?

exuin | 2021-05-22 15:58

What is MODE_STATIC?

It is a constant from RigidBody2D. I have just updated the code in my post to make it clear.

Can you try using RigidBody2D.MODE_STATIC instead?

Yeah, I tried this one too. The result was the same.

atmeo | 2021-05-23 07:18