1
Fork 0
mirror of https://github.com/RYGhub/the-cold-night.git synced 2024-11-21 20:24:20 +00:00

🧹 Skip transforming from rad to deg to rad

This commit is contained in:
Steffo 2022-04-03 02:43:23 +02:00
parent 2efaf67003
commit 1546d40b53
Signed by: steffo
GPG key ID: 6965406171929D01
2 changed files with 3 additions and 13 deletions

View file

@ -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)

View file

@ -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)