0 votes

Sorry, I couldn't think of a better way to phrase this question.

Basically, I have two instances of the same scene (called Person) in another otherwise empty scene just for testing. Each Person is just a RigidBody2D with a script, and has a Sprite and a CollisionShape2D as children. I followed some tutorials online to allow these to be clicked and have some functionality. So the input_event signal of the RigidBody2D is connected to its own script, and I have the following for the function (using GDscript):

func _on_RigidBody2D_input_event(viewport, event, shape_idx):
    if event is InputEventMouseButton && event.pressed && event.button_index == BUTTON_LEFT:
        #just changes some variables and sends a signal

I have each Person set up so that after they have been clicked, I can move them around with the arrow keys (using the method they use in the "Dodge the Creeps" tutorial where a vector multiplied by delta is added to the node's position). This mostly works great. My issue is that after moving a Person and then clicking off to another person, clicking back to the Person I moved is very difficult. After some debugging, I found that the region I have to click to "take control" of the person again is the region the person originally occupied when I launched the scene. So no matter where I move a person, to take control of it again, I have to click where they originally were.

The weird thing is, when I turn on the debug option to show collision shapes, the shapes still follow a Person as it moves. But I still have to click the place where the shape originally was in order to take control of the Person again.

Sorry if I didn't explain very well, I'm pretty new to using Godot and this problem is just baffling me.

EDIT: My question hasn't even been approved yet, but I added a functionality to Person where clicking them also switches the camera to its Camera2D child, and suddenly the problem has fixed itself. I don't really understand.

in Engine by (34 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.