diff --git a/bullet.tscn b/bullet.tscn index 18239bc..4eaeb60 100644 --- a/bullet.tscn +++ b/bullet.tscn @@ -6,10 +6,9 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_t8jlo"] size = Vector2(8, 2) -[node name="Bullet" type="RigidBody2D"] +[node name="Bullet" type="CharacterBody2D"] collision_layer = 0 collision_mask = 2 -gravity_scale = 0.0 script = ExtResource("1_67gkv") [node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/scripts/bullet.gd b/scripts/bullet.gd index 1518c43..8aeb38a 100644 --- a/scripts/bullet.gd +++ b/scripts/bullet.gd @@ -1,8 +1,10 @@ -extends RigidBody2D +extends CharacterBody2D -@export var initial_velocity = 800 +@export var speed = 800 @export var direction: float = 0 func _ready() -> void: rotation = direction - linear_velocity = Vector2.from_angle(direction) * initial_velocity + +func _physics_process(delta) -> void: + var collisions = move_and_collide(direction * speed * delta)