Godot Version
4.6.1
Question
I have a system where the player can place items into the world. Since I don’t want the player to be able to place right next to a wall, or in a very small area, I’m trying to create a system that checks if where the player is placing is touching something (like a wall) and abort if it does. However, it just…doesn’t work? I’ve tried everything, checking collisions after or before an item is placed down, using raycasters even, but nothing works. Currently I have a Area3D that moves to where the item will be placed down and if the Area3D has overlapping bodies/areas, it aborts. However nothing happens? I changed the Area3D’s collision shape to be super huge even and it still didn’t work!
The code for the player placing an item is as follows, the raycast is what I use to figure out where the player is trying to place at, the Area3D is what I’ve (tried to) use to detect collisions and abort if it is colliding.
func putdown():
if raycast.is_colliding():
raycastcollisionpoint = raycast.get_collision_point()
currentplayerrotation = $Pivot/Camera3D.global_rotation
$Area3D.position = raycastcollisionpoint
$Area3D.monitoring = true
if $Area3D.has_overlapping_bodies():
$Area3D.monitoring = false
return
else:
emit_signal("sendraycastcollision",raycastcollisionpoint,currentplayerrotation)