0 votes

I want to set the maximum velocity to a RigidBody2D, so it can't exceed the speed limit.

asked Sep 14, 2016 in Engine by Skyfrit (391 points)

1 Answer

+2 votes
Best answer
var max_speed = 100


if abs(get_linear_velocity().x) > max_speed or abs(get_linear_velocity().y) > max_speed:
    var new_speed = get_linear_velocity().normalized()
    new_speed *= max_speed
answered Sep 15, 2016 by ericdl (1,252 points)
selected Sep 16, 2016 by Skyfrit

Thanks for the answers.

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.