0 votes

inside of this piece of code:

private void onArea2Dbodyshape_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;

asked May 21 in Engine by Moises Fuentes (15 points)

1 Answer

0 votes
Best answer

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);
    }
}
answered May 25 by juppi (304 points)
selected Jun 9 by Moises Fuentes
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 How to use this Q&A? before posting your first questions.