+1 vote

Hi guys,

how is it possible to walk on a line or path only like in "Super Mario World" for SNES to get from level to level?

I tried to hook up my KinematicBody2D with area_entered to "walk" along the Path, but it goes only oneway. An when I entered the Area2D I, have to leave the Area2D before i can enter a second time.

Do you have some ideas?

Thanks a lot.

in Engine by (20 points)

2 Answers

+2 votes
Best answer

Well, if you're using Path2D- and PathFollow2D-nodes (as both the title and the tags suggest you do) it's rather simple: all you have to do is translate the player inputs into offsets along the path - either forward or backward.

func _physics_process(_delta):
    if Input.is_action_pressed("ui_right"):
        $Path2D/PathFollow2D.offset += 1
    elif Input.is_action_pressed("ui_left"):
        $Path2D/PathFollow2D.offset -= 1

    $Player.position = $Path2D/PathFollow2D.position
by (10,391 points)
selected by
0 votes

All things considered, in case you're utilizing Path2D-and PathFollow2D-hubs (as both the title and the labels recommend you do) it's somewhat basic: you should simply make an interpretation of the player contributions to counterbalances along the way - either forward or in reverse.

by (14 points)
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.