Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

There are a few ways to do this depending on what the other "something" is that you are checking for and how you intend to use it.

Something to keep in mind - unless you are doing a physics-based game (like angry birds or breakout), you probably don't want to use a RigidBody. If you are making a game that needs a RigidBody, it is often better to simply put your collision detection code on the non-RigidBody object. (Eg: In a "Breakout" clone, have the StaticBody blocks detect when they are hit by a RigidBody ball, rather than having the ball detect when it hits a block.)

If you are sure you want to use the RigidBody's collision detection to detect when it has collided with other BODIES (not Area2Ds), then you can simply check "Contact Monitor" for the RigidBody and set its "Contacts Reported" to a number higher than 0 (I recommend 1, but no more than 3 or 4). Then you can use the RigidBody's "body_entered" signal from the node tab.

To check if it collided with a specific item, you can use either "is_in_group() or "extends".

Examples: 

func _on_MyRigidBody_body_entered(body: Node) -> void:
     if body.is_in_group("Bullet"):
        #code for being shot by a bullet

OR...

func _on_MyRigidBody_body_entered(body: Node) -> void:
     if body extends bullet:
        #code for being shot by a bullet

If you want to detect AREAS as well as BODIES, another option is to simply wrap an Area2D that around your RigidBody (though the Area2D's collision shape has to be OUTSIDE the Rigidbody's collision shape). Then you can use the Area2D's "on enter" signals to detect when the RigidBody has collided with something. This is especially useful for when you want to have an early notification range. (Think of how Peggle slows down and zooms in when a shot attempts to hit the final peg...you can reproduce that effect by wrapping a large Area2D around either the ball or peg and have it kick off the effect if there is only one peg remaining.) 

A final option is use Raycasts, but there can be problems with this approach. 
https://kidscancode.org/blog/2018/03/godot3_visibility_raycasts

Here are a couple of useful videos related to this subject. Though neither provides a very straight-forward answer to your question, it might help if you run into problems as this can be a fairly complicated space to navigate.


Thanks for the response, I think that I’ll use the rigid body itself for detections.

I ended up using the rigid body to detect the collision and it works great. Thanks for the advice!

Awesome!