0 votes

I can't figure out how to get an Area2D to move other objects in the scene with code using the area_entered signal. I think the code would maybe need a transform 2D?

Godot version 3.2.3
in Engine by (19 points)

Why can't you just change the position of the area that entered it?

Because that's exactly what I don't know how to do.

1 Answer

0 votes

The area_entered signal has the area that entered as an argument. In your _on_area_entered(area) function, or whatever you called it, just change the position of the area with

area.position = new_position
by (7,190 points)

I'm not exactly sure what to put into the space where new_position is. I can only seem to put in a single number before it stops working.

Position is a Vector2. So you'll need to put a value of that type in there.

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 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 webmaster@godotengine.org with your username.