Get Vector2 of collided Area2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JohnMaddenGodot

I am trying to get the y position of the Area2D that the player collides with, however I keep receiving “Invalid call. Nonexistent function ‘Vector2’ in base ‘Area2D’.” Does Area2D not have Vector2?

func _on_LedgegrabHook_area_entered(area):
     var ledgegrabPos = area.Vector2()

Apparently Area2D does not have a Vector2 property, however I have attached a CollisionShape2D node to it which should have one. How would I get the Vector2 of a subnode? when the player enters the Area2D?

:bust_in_silhouette: Reply From: jgodfrey

Vector2 is not a property - it’s a data type. For your question, an Area2D (and anything else that extends Node2D) has a position property that IS a Vector2. I assume that’s the property you’re looking for. So, you probably want this:

var ledgegrabPos = area.position.y