rotoboy mechanic
This commit is contained in:
parent
dd54e286d8
commit
aaf9278350
4 changed files with 89 additions and 31 deletions
35
objects/rotoboy/roto_boy.gd
Normal file
35
objects/rotoboy/roto_boy.gd
Normal file
|
@ -0,0 +1,35 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
@export var speed: float = 0.0
|
||||
@export_custom(0, "radians_as_degrees") var rotation_speed: float
|
||||
@export var launch_speed: float
|
||||
|
||||
@export_group("Internal References")
|
||||
@export var rotation_pivot: Node2D
|
||||
@export var collision_shape: CollisionShape2D
|
||||
|
||||
|
||||
var _player: Player = null
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_zero_approx(speed):
|
||||
collision_shape.disabled = false
|
||||
rotation_pivot.rotation = 0.0
|
||||
else:
|
||||
collision_shape.disabled = true
|
||||
rotation_pivot.rotation += rotation_speed * delta
|
||||
if _player:
|
||||
var dir = -to_local(_player.global_position).orthogonal()
|
||||
_player.launch(_player.velocity + dir * launch_speed * speed * delta)
|
||||
|
||||
|
||||
func _on_player_detector_body_entered(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
_player = body
|
||||
|
||||
|
||||
func _on_player_detector_body_exited(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
_player = null
|
Loading…
Add table
Add a link
Reference in a new issue