Currently trying to get bullets in my game to collide with the environment. They collide with enemies but not the floor or walls.
Here’s the bullets code, tree and inspector bullets are on collision layer 6 with walls and floors on 3
func _on_body_entered(body: Node3D) -> void:
#debug body
print("hit: " + str(body))
#check for damage function in body
#set position for range calc
#calculate damage using the range on the curve
#deal damage to body
if "hit" in body:
position = body.get("position")
shot_range = (position-starting_pos).length()
final_damage = damage * damage_dropoff.sample(shot_range / bullet_range)
#debug damage
print("damage=" + str(final_damage))
body.hit(final_damage)
#delete bullet
queue_free()
There can be a few reasons why this happens, but based on your screenshots I can offer a few things that might help.
For one, I’m sure you already have, but make sure that your “Area3D” has monitoring set to true, so it can monitor bodies entering and exiting it.
Next, if your Wall is the CSGBox3D, then make sure it has use_collision ticked, and have it’s layers and mask set correctly.
If your MeshInstance3D has anything to do with the walls, make sure it has a Mesh attached to it, then generate a CollisionShape based on it by clicking here:
This goes for both the bullet itself and the Floor.