0 votes

I don't get what's happening, the code says its "Error change_scene(path: String)

  • extends KinematicBody2D

    var velocity = Vector2(0,0) const speed = 80 const gravity = 3 const
    jump_force = -80

    func physicsprocess(delta): if
    Input.isactionpressed("uiright"): velocity.x = speed
    $AnimatedSprite.play("Run") $AnimatedSprite.flip
    h = false

    elif Input.isactionpressed("uileft"): velocity.x = -speed
    $AnimatedSprite.play("Run") $AnimatedSprite.flip
    h = true

    else: $AnimatedSprite.play("Idle") velocity.x = 0 if not
    isonfloor(): $AnimatedSprite.play("Jump") velocity.y =
    velocity.y + gravity if Input.isactionjustpressed("uiup") and
    isonfloor() || Input.isactionjustpressed("uiup") and
    isonwall(): velocity.y = jumpforce velocity =
    move
    and_slide(velocity,Vector2.UP) velocity.x =
    lerp(velocity.x,0,0.2)

    func onfallzonebodyentered(body):
    gettree().changescene("res://Level1.tscn")

in Engine by (48 points)

1 Answer

+1 vote
Best answer

the change scene functions needs a "scenepath". not a string.

change the string in the change_scene() function to load("res://Level1.tscn") so its instead gonna change to a scene, and not a string

hope this fixes your problem !

by (439 points)
selected by

Thanks for helping me. I tried your way and it still didn't work, and i found that changing the collision layer helped tho..

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.