0 votes

Hello, I'm trying to learn godot4.0 using HeartBeast action RPG tutorial (which is on the older version of Godot) and everything was fine until I tried to use clamped()
a picture of the code

am I missing something?

Godot version 4.0
in Engine by (20 points)

1 Answer

+2 votes
Best answer

The godot editor has a built-in documentation.
You can Ctrl+Click on a type (Vector2 in this case) and see it's entire description.
It says it doesn't have a clamped() function, you can confirm it for yourself.
Instead it has a function called clamp(), but it doesn't take the same kind of parameter.

Checking out the online documentation (specifically the 3.x) version, you can see in the description of Vector2.clamped() that it is depricated, and limit_length() should be used instead. This function is present in the 4.0 version as well.

by (1,607 points)
selected by

As a side note, CharacterBody2D has a built-in velocity member, you don't need to define it yourself.

thanks a lot ! yes I had to use limit_length() instead of clamped(), it works perfectly fine now.

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.