diff --git a/src/entities/behaviours/BulletMovement.gd b/src/entities/behaviours/BulletMovement.gd index 6f2b8b6..2fb4548 100644 --- a/src/entities/behaviours/BulletMovement.gd +++ b/src/entities/behaviours/BulletMovement.gd @@ -1,19 +1,9 @@ extends Node onready var target: KinematicBody2D = get_parent() -onready var angle: float = deg2rad(target.get_rotation_degrees()) export var movement_per_second: float = 400.0 -var direction : Vector2 = Vector2(0,0) -func _ready(): - direction = Vector2.ZERO - - direction += sin(angle) * Vector2.DOWN - direction += cos(angle) * Vector2.RIGHT - - if direction.length() > 1: - direction.normalized() - func _physics_process(delta): + var direction = Vector2(cos(target.rotation), sin(target.rotation)) var _motion: Vector2 = target.move_and_slide(direction * movement_per_second) diff --git a/src/entities/behaviours/BulletSpawn.gd b/src/entities/behaviours/BulletSpawn.gd index 1a90a8e..be97442 100644 --- a/src/entities/behaviours/BulletSpawn.gd +++ b/src/entities/behaviours/BulletSpawn.gd @@ -11,6 +11,6 @@ func _process(_delta): func _on_Click(): var new_bullet = bullet.instance() new_bullet.set_position(spawner.position) - var bullet_rotation = rad2deg(new_bullet.get_angle_to(get_global_mouse_position())) - new_bullet.set_rotation_degrees(bullet_rotation) + var bullet_rotation = new_bullet.get_angle_to(get_global_mouse_position()) + new_bullet.set_rotation(bullet_rotation) add_child(new_bullet)