#HeartBeast ARPG help

1 messages · Page 1 of 1 (latest)

spark drift
#

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.

#

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

#

Here is the video

mellow brook
#

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.

spark drift
#

Trying it again doesn't appear to make a difference

mellow brook
#

What do you mean? The game still doesn't run?

spark drift
#

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

placid otter
spark drift
#

What version are you using?

mellow brook
placid otter
#

you can clamp x y separatly

placid otter
spark drift
#

Oh...?

#

Can you look at the code and compare. Its on the top of the thread.

placid otter
#

remove delta everywhere

spark drift
#

Why?

placid otter
#

its used in move_and_slide function

mellow brook
#

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

spark drift
#

For the limit_length?

placid otter
#

try without delta

spark drift
#

Cleaning right now

#

It worked. Holy crap. Thank you both.gdclap

placid otter
spark drift
#

It seemed to go off of frames instead of max speed

#

using delta

placid otter
#

so it was moving very slowly?

spark drift
#

yes

placid otter
#

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

spark drift
#

Interesting. Thanks for the insight.