godot 2d shooting code example
Example 1: shooting gdscript
- Area2D ("Bullet")
- Sprite
- CollisionShape2D
Example 2: shooting gdscript
extends Area2D
var speed = 750
func _physics_process(delta):
position += transform.x * speed * delta
func _on_Bullet_body_entered(body):
if body.is_in_group("mobs"):
body.queue_free()
queue_free()