0 votes

I've made a kind of gate. Check a video: https://youtu.be/idbKdaFdkLM
I used RigidBody and set Custom Integrator true. Then I wrote this code:

extends RigidBody2D

func _integrate_forces(state):
    linear_velocity = Vector2(0, 0)

In the video you can see a console that outputs Y position of the object and position still changes. My method couldn't make it stop completely. If I directly change position, object doesn't revolve at all.

So can I freeze RigidBody on the place without making it Kinematic or Static, because it ruins the main feature of this object

in Engine by (12 points)

2 Answers

0 votes

I can't tell you why your approach doesn't work as expected (probably rounding errors in the rotation), but I can tell you there's a better way to do it - by using a PinJoint2D node:


by (1,758 points)
0 votes

If you are talking about the Godot icon as a "gate", then the reason it isn't working is because it is rotating and thus has no linear_velocity.

But the best way to do this is this:


When you want to stop it.

and then do:


when you want it to move again.

by (616 points)
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 Frequently asked questions and 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 [email protected] with your username.