How do I make collectible objects in a 3d game(with gdScript)?

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

Okay so I am new to Godot and I have enjoyed the engine so far, but I can’t figure out how to make a collectible item in a 3d game. All the tutorials and stuff I can find are for 2d games. The game I am making is a simple game where the player controls a ball and rolls around the level collecting cubes. My problem is that I can’t figure out how to make the score increase when I touch a cube. I can change the text of the score easily but I don’t know how to detect the collision between the player and the cube. I don’t even know how to detect collisions in a 3d game. I also want the cubes to disappear when collected. Does anyone know how to detect the collision? I have already added the cubes to a group called coins if that helps at all. Can someone please help me?

:bust_in_silhouette: Reply From: kidscancode

Most tutorials start out with 2D content for a reason - because 2D is easier to deal with when you’re learning. Much of Godot’s nodes work the same way in 2D and 3D. For example, the official 2D tutorial shows how to detect two object colliding:

https://docs.godotengine.org/en/latest/getting_started/step_by_step/your_first_game.html

The physics introduction gives more detail about the different types of collision nodes:

To summarize:
In 2D, you’d make the cubes Area2D nodes and connect the body_entered signal to detect the player picking them up. In 3D, the node is Area, and everything else is the same.

Oh I think I get it so I can just attach an area node to my cubes? I didn’t realize that that was a thing I thought that area2d was a physics body. Maybe it is, but anyway thank you for the help I guess I’ll attach an area node to my cubes and see what the tutorials have to say.

Dragon11705 | 2019-06-04 19:50

I tried it and it worked thank you for the help kldscancode :smiley:

Dragon11705 | 2019-06-04 20:31