|Topic was automatically imported from the old Question2Answer platform.
Hi! I’m new to the engine and am having trouble getting a teleporter I have set up triggering. I have a KinematicBody2D (my player) and an Area2D (the teleporter) set up in the same scene. I have this code put on the teleporter:
if "ch_p1" in body.name:
print(str('Player has entered'))
Neither the error message nor the teleportation function (tp_r) trigger when I enter the Area2D. I’ve tried alternatives like area_entered and that didn’t work either, and my KinematicBody2D has no trouble colliding with the ground I have set up. They are all on the same collision layer. Is there some piece I’m missing along the way? Here are my node trees for everything relevant:
Have you set up a collision shape for all the nodes requiring it? All
CollsionShapesneed… well, a shape.
body.tp_r(). It would normally throw an error message, but you never know.
Are you sure this “ch_p1” is part of the string you are checking? Maybe you would like to print something when the collsion occurs just to see if the
Area2Dis detecting collisions?
johnygames | 2020-01-04 23:26
The CollisionShape2Ds definitely have shapes, so that isn’t the issue. I noticed the missing parenthesis just before you responded. Interestingly, it never gave me an error message for those. I fixed it anyways but nothing changed.
I have in the code I posted an error message but it has never once shown up, so the objects are probably not colliding. I just can’t figure out why.
l0stwoods | 2020-01-04 23:48
So, let me get this straight, have you tried this?
It is important that you rule out the possibility that the Area2D is not detecting collisions.
johnygames | 2020-01-05 00:42