Alright, so I'm going through the HeartBeast Action RPG video series and I have run into an issue. Im using the latest version of 3.5 and the velocity.clamped is no longer supported and is replaced with limit_length. I cant see to figure out how to implement that into my code and I was wondering if someone could please help me understand.
#HeartBeast ARPG help
1 messages · Page 1 of 1 (latest)
extends KinematicBody2D
const FRICTION = 25
const ACCELERATION = 25
const MAX_SPEED = 200
var velocity = Vector2.ZERO
func _physics_process(delta):
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
velocity += input_vector * ACCELERATION * delta
velocity = velocity.clamped(MAX_SPEED * delta) #This doesnt work in 3.5 to due clamped being dead
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
print(velocity)
move_and_collide(velocity * delta)
This is my current code
Learn to make an Action RPG in Godot Engine 3.2. Godot is a wonderful free and open source game engine designed for indies. It is powerful and flexible.
In this video you will learn about delta and how to apply it to your velocity and acceleration to get smooth movement.
Fixing Jitter and Stutter: https://docs.godotengine.org/uk/latest/tutori...
Here is the video
As the message states, clamped is deprectated (no longer used) but you should use limit_length instead. So where it says velocity.clamped(MAX_SPEED * delta) change it to velocity.limit_length(MAX_SPEED * delta)
Btw you can embed formatted code snippets directly into Discord by surrounding the code block with triple backticks. Adding swift at the top also gives it some basic syntax highlighting.
```swift
print("Hello World!")
```
This produces a code block that looks like this:
print("Hello World!")
You can also format code inline with single backticks: `my_method()` => my_method()
For sharing large scripts, please post your script to a pastebin like https://hastebin.com/ or even consider sharing a remote Git repository on GitHub or GitLab.
I appreciate the insight. When I initally tried to do that, the game still acted as if I left it the same.
Trying it again doesn't appear to make a difference
What do you mean? The game still doesn't run?
No the game runs, however he focuses the video on the actual movement of the sprite(player).
Going off of the video, you set the friction, Acceleration, and the Max Speed.
and apply to velocity
I got to the point where he added the line in question and the speed is not functioning properly
I did discover that removing delta makes a slight difference, but not the outcome I was looking for
wait but i use clamped() in my script and it works
What version are you using?
He's on Godot 3.5
you can clamp x y separatly
me to
remove delta everywhere
Why?
its used in move_and_slide function
Yes you can still use clamp on integers/floats but not on a Vector2, the name has bee changed to limit_length, but it still behaves the same as clamped
i use it on a vector
For the limit_length?
try without delta
when it was broken did you just not move or you didnt have max speed?
so it was moving very slowly?
yes
that explains everything
delta is a really small number and multiplying something with it will also make that number small
basically your max speed was very small
Interesting. Thanks for the insight.
