How to check if my player have collision with coins [3D]
Asked Answered
S

2

0

Hey. I don't understand how to do such simple thing.
Here's my code:

extends Area3D

func _on_body_entered(body):
	print("body: " + str(body))
	if body.name == "coin":
		body.queue_free()

I tried it, but nothing happens when my player collides with the coin object.
Is there 100% way to collect the coin correctly?

Sawdust answered 2/12, 2023 at 8:31 Comment(0)
C
0

I assume the script above is attached to a node that is a child of the player node. If that is the case then:

First thing to check is if the body_entered signal is actually connected to the _on_body_entered function.

Second thing to check is if collision_layer and collision_mask are set correctly.

Cruzcruzado answered 2/12, 2023 at 9:1 Comment(0)
G
0

Cruzcruzado the script above

I think you forgot something. 😉

Graig answered 2/12, 2023 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.