'Player' won't collide to the next level

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Natwasnttaken

My friend was having a change scene problem when she was working on her project and she is learning godot, of course. The code works but the ‘player’ wont collide with it (the kineticbody only walk through it instead of teleporting to the next scene)

here is the code sample:

extends Sprite

func _on_HitBox_area_entered(area):
    if area.is_in_group("Player"):
        get_tree().changescene("res://Level" + str(int( get_tree().current_scene.name) + 1) + ".tscn"

your created a called “Player” group?

BVictor | 2021-02-07 00:04

:bust_in_silhouette: Reply From: BVictor

I think will be more easy if your check the player name when collide. example:

func _on_area_entered(area):
    if area.get_parent().get_name() == "Player:
        get_tree().changescene("SceneName")

remembering its is a area + area collision. the player needs a area too.

the problem is solved, thank you :>

Natwasnttaken | 2021-02-07 00:52

:bust_in_silhouette: Reply From: yrtv

From Area2D — Godot Engine (stable) documentation in English

area_entered ( Area2D area )

Emitted when another area enters.

Area2D entering HitBox is HurtBox(Player is not Area2D, it’s KinematicBody2D). You probably not added HurtBox to Player group (It’s child of Player Node not member of Player group). Add HurtBox to Player Group in Goups interface.