C# - how to know the position of an object that collide

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

inside of this piece of code:

private void _on_Area2D_body_shape_entered(int body_id, object body, int body_shape, int area_shape)
{
if(body is Player){
//do something
}
}

how can I know the global position of the “body” since it is an “object” I cannot do this:

body.globalPosition;

:bust_in_silhouette: Reply From: juppi

Just use RigidBody as Parameter for your signal function. Like that:

private void _on_Area2D_body_entered(RigidBody body)
{
    if (body is RigidBody)
    {
        GD.Print(GlobalPosition);
    }
}