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

ok so im trying to figure out a way how to make it so when the player comes into contact with the area 2D and once they jump it should teleport them but for some reason its doing the oppisote whenever i get near the collison shape it says its still not true but when i walk away from it after entering it it says its true. help?

Can you upload the project somewhere, or at least post the relevant code here?

Thomas Karcher | 2023-06-22 08:00

sorry it took me so long to respond it wont let me send the images here you think you could add me on discord?

yellowJUSTice | 2023-06-23 20:06

Sorry, I’m not on Discord. But the code (as plain text) is enough. No need to post images.

Thomas Karcher | 2023-06-23 20:59


extends Area2D

var entered = false

func _on_Area2D_body_entered(body: KinematicBody2D):
print(“entered in now false”)
entered = false

func _on_Area2D_body_exited(body):
print(“entered in now true”)
entered = true

func _process(delta):
if entered == true:
if Input.is_action_just_pressed(“ui_up”):
get_tree().change_scene(“res://tutorial act 1.1.tscn”)

yellowJUSTice | 2023-06-23 22:09

:bust_in_silhouette: Reply From: Thomas Karcher

This is one of these cases where rubber duck debugging (Rubber duck debugging - Wikipedia) is really helpful: Try to explain the code you pasted to your rubber duck, cat, or anyone nearby:

When the body enters the Area2D, I set the “entered” variable to “false”. Because… oh, wait.