| Attention | Topic was automatically imported from the old Question2Answer platform. | |
| Asked By | Elendir |
I have Object1 of type Area2D and Object2 of type Area2D.
Object1 has the following function (attached to a signal area_entered(area; Area2D):
# This function handles collisions between objects (Area2Ds)
func bounce_from_area(var who):
hit_object = who
now hit_object is a global variable in Object1. So whenever Object2 (Area2D) collides with my Object1, Object1 stores the collided object in hit_object variable.
So let’s say Object1 was hit by Object2. Now Object1.hit_object stores Area2D object. If I use hit_object.name I would get “Object2” name). All is fine up to this point.
Now I’d like to get to the child of Object2 stored in hit_object variable. But I can’t.
The below code doesn’t work:
var temp1 = hit_object.AnimatedSprite.animation
I get the following error:
Invalid get index 'AnimatedSprite' (on base: 'Area2D (Objectr1.gd)').