How can I exclude my player from a collision parameter?

Godot Version



sorry if this is a really dumb question but I’m trying to make a game with a gun that rotates and my problem is that in certain rotations the end of the gun will overlap the player which means the bullets delete themselves as soon as they are shot because they get deleted if they hit something.
This is basically what I want to do but I’m not sure how:

func _on_body_entered(body):
	if body != CharacterBody2D:

Easy solution:

func _on_body_entered(body):
	if not body is CharacterBody2D:

Proper solution: setup physics_layers in a way that player bullets never collide with the player in the first place. So you don’t even need to check what the bullet had hit.

1 Like


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.