0

this is my first time posting a question here so we'll see how this goes.

I've created a scene in Godot which is set up as

Area2D
|
|-AnimatedSprite
|
|-CollisionShape2D

Attached is the following script:

func _input_event(_viewport, event, _shape_idx):    
    if event is InputEventMouseButton \
        and event.button_index == 1 \
        and event.is_pressed():
        print ("success")

During game setup, the main scene's script creates several instances of this scene at different coordinates. The problem is that clicking on them does not trigger the expected print statement. In my troubleshooting I manually added an instance of the scene in the same spot on the scene tree as the ones created by the script and this instance inexplicably does trigger when I click on it.

Any thoughts? What could I be overlooking?

  • 1
    Usually the issue with not receiving input is that something else is getting (notably, controls take priority for mouse input, even if they are in the background). However, I can't tell what is going on your case. I'd say, run the project and while it is running, look at the remote tab on the scene panel, and see if there is something wrong with the instanced added by code. Perhaps telling Godot to show colliders in the debug menu could also reveal something. – Theraot Nov 28 '21 at 08:59
  • Thank you! Turning on colliders did help. I didn't know that was an option. Turns out I was changing the position of the sprites in code without moving the collision shapes along with them. – Magnetic_Cassie Nov 28 '21 at 17:10

0 Answers0