• 2D
  • How do I make the collision shape invisible?

Hi there! I'm trying to code my first game and am using a bunch of tutorials to piece them together. I'm trying to have this Rice Ball show up, only after a platform is pressed. I have to where the rice ball doesn't show up until the platform is pressed; however, if you run into the area it'll take you to the next stage. Here's my code for the Rice Ball:

extends Area2D

export(String, FILE, "*.tscn") var target_stage

func _ready(): visible = false

func _on_RedPlatform_pressed(): visible = true

func _on_RiceBall_body_entered(body): if "Player" in body.name: get_tree().change_scene(target_stage)

Thanks in advance:)

The visible flag just shows or hides the item, it doesn't disable it.

One simple way to do this is to check if it's visible in your code:

func _on_RiceBall_body_entered(body):
   if "Player" in body.name and visible:
      get_tree().change_scene(target_stage)