The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I'm trying to have a node change position, and then within the same frame be able to be detected by an Area2D that it has now moved into. My code in the test I ran looks as follows:

onready var a = $a
onready var b = $b

func test():
    a.position = b.position
    print (a.get_overlapping_areas())

func _physics_process(delta):
    if Input.is_action_just_pressed("ui_accept"):

The first time I hit enter, I get a blank array. Every time afterwards I get an array with a ref to b in it. Clearly the collision isn't being updated on the same frame as the motion.

I've tried using force_update_transform() in between the position change and the get_overlapping_areas() call, but that doesn't change anything. I'd appreciate any suggestions as to what I should try.

in Engine by (449 points)

Have you tried passing it as an argument?

func _physics_process(delta):
    if Input.is_action_just_pressed("ui_accept"):
        a.position = b.position

func test(overlapping_areas):

It doesn't change the behavior, unfortunately.

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.