![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | denxi |
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"):
test()
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.
Have you tried passing it as an argument?
func _physics_process(delta):
if Input.is_action_just_pressed("ui_accept"):
a.position = b.position
test(a.get_overlapping_areas())
func test(overlapping_areas):
print(overlapping_areas)
Magso | 2020-04-17 15:36
It doesn’t change the behavior, unfortunately.
denxi | 2020-04-17 22:35