The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes


how can i check if an area2d is colliding with an physicsbody(static,kinematic and rigid) in the body_entered signal

Godot version 3.4
in Engine by (77 points)

1 Answer

0 votes

The body_entered signal will be generated by the Area2D node whenever a PhysicsBody2D node enters the collision shape of the Area2D node. You will need to connect the Area2D node's body_entered signal to the function that you want it to trigger. The triggered function will be passed an argument (the PhysicsBody2D node that entered the area). So make sure the triggered function has a single parameter (see code snippet).

func on_Area2D_body_entered(body):
    # Put here the code you want to run whenever a body enters the area.
    # Remember that 'body' will be the PhysicsNode2D that entered the area.
    print( + " entered the area")
    print("velocity " + str(body.linear_velocity)) # assumes body is RigidBody2D, since KinematicBody2D and StaticBody2D nodes don't have a linear_velocity property

Remember that I had to connect the Area2D node's body_entered signal to this function, and that this function could be in the Area2D node or it could be in any other node. For information about connecting signals to functions I recommend the signals tutorial contained in the docs. Also, feel free to ask additional questions.

by (180 points)
edited by

That makes sense Iam totally stupid
Anyway thx

You're welcome

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 Frequently asked questions and 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 [email protected] with your username.