0 votes

I have been following GDquest's "Your first game" tutorial, I made the function get_direction, however, it is not returning the Y component of Vector2. Here is the code:

```extends Actor

var strength_track = 0.0

func physicsprocess(delta: float) -> void:
var movedir = getdirection()
print(movedir.x)
if move
dir.x == 0.0:
$AnimatedSprite.play("Idle")
elif movedir.x < 0.0:
$AnimatedSprite.flip
h = true
$AnimatedSprite.play("Walk")
elif movedir.x > 0.0:
$AnimatedSprite.flip
h = false
$AnimatedSprite.play("Walk")
velocity = speed * movedir
velocity = move
and_slide(velocity)

func getdirection() -> Vector2:
return Vector2(
Input.get
actionstrength("Right") - Input.getactionstrength("Left"),
-1.0 if Input.is
actionjustpressed("Jump") and isonfloor() else 1.0
)```

in Engine by (17 points)

Actually your code should always return a value as conditional statement returns 1.0 as default on Y.

How can you say it is not returning a value?
As of now the default applies gravity and makes the player fall when it is not on floor.
Jump applies -1 giving a vertical impulse, only just after Jump button is pressed.

Just to verify you could mess around using isactionpressed() to verify that the jump input is correct.

Please log in or register to answer this question.

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.
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 webmaster@godotengine.org with your username.