0 votes

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

Godot version 3.3.1
in Engine by (12 points)
edited by

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

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.