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:
parent
2efaf67003
commit
1546d40b53
2 changed files with 3 additions and 13 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue