I can't figure out how to hide and show a line 2D at certain times (GDScript)

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

So I am working on maing my forst game on godot. SO whenever my player is wall sliding the line 2D which I’m using as a trail is showing. I want to hide the linw2D while wall sliding but can’t figure out how to do that.

:bust_in_silhouette: Reply From: hudadev

I’m not entirely sure if this answers your question but here’s what I would do:

For the player, be sure to have a collision shape/polygon. And from there, there should be a signal you can emit for whenever the collision shape collides with something. So you would connect that signal and then inside that signal function, you would get the node and hide it. So it would go by something like this:

func Collision_Shape_2d_Collided:
       $Line2D.visible = true

(remember that it wouldn’t be exactly the same because i don’t know what your nodes are named!)