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;

in Engine by (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);
    }
}
by (346 points)
selected by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.