add room tilt
This commit is contained in:
@@ -38,6 +38,10 @@ enum TileType { PROGRESS, HEAL, ENEMY }
|
||||
@export var _enemy_tiles_init_amount: float = 2
|
||||
@export var _enemy_tiles_increase: float = 1.0 / 8.0
|
||||
|
||||
@export_group("Animation")
|
||||
@export var _tilt_amount: float = 0.025
|
||||
@export var _tilt_speed: float = 1
|
||||
|
||||
var _progress_tiles_pressed: int
|
||||
var _progress_requirement: int
|
||||
|
||||
@@ -46,6 +50,9 @@ var _progress_tiles_amount: float
|
||||
var _enemy_tiles_amount: float
|
||||
|
||||
var _tween: Tween
|
||||
var _base_position: Vector3
|
||||
var _base_rotation: Vector3
|
||||
var _tilt_rotation: Vector3
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -61,6 +68,17 @@ func _ready() -> void:
|
||||
_generate_tiles()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
position = _base_position
|
||||
rotation = _base_rotation
|
||||
|
||||
var tilt := Vector3(
|
||||
_player.position.z * _tilt_amount, 0, -_player.position.x * _tilt_amount
|
||||
)
|
||||
_tilt_rotation = (_tilt_rotation.lerp(tilt, _tilt_speed * delta))
|
||||
rotation += _tilt_rotation
|
||||
|
||||
|
||||
func progress() -> void:
|
||||
_progress_tiles_pressed += 1
|
||||
if _progress_tiles_pressed == _progress_requirement:
|
||||
@@ -97,9 +115,11 @@ func _flip(direction: Vector3) -> void:
|
||||
if _tween:
|
||||
_tween.kill()
|
||||
|
||||
position = direction * _flip_distance
|
||||
_base_position = direction * _flip_distance
|
||||
var axis := direction.cross(Vector3.UP)
|
||||
rotate(axis, -deg_to_rad(_flip_angle_deg))
|
||||
_base_rotation = (
|
||||
Basis.IDENTITY.rotated(axis, -deg_to_rad(_flip_angle_deg)).get_euler()
|
||||
)
|
||||
|
||||
await get_tree().create_timer(_flip_freeze_time).timeout
|
||||
|
||||
@@ -107,17 +127,17 @@ func _flip(direction: Vector3) -> void:
|
||||
|
||||
_generate_tiles()
|
||||
|
||||
_tween = create_tween().set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
|
||||
_tween = create_tween()
|
||||
(
|
||||
_tween
|
||||
. tween_property(self, "position", Vector3.ZERO, _flip_duration_pos)
|
||||
. tween_property(self, "_base_position", Vector3.ZERO, _flip_duration_pos)
|
||||
. set_trans(Tween.TRANS_ELASTIC)
|
||||
. set_ease(Tween.EASE_OUT)
|
||||
)
|
||||
(
|
||||
_tween
|
||||
. parallel()
|
||||
. tween_property(self, "rotation", Vector3.ZERO, _flip_duration_rot)
|
||||
. tween_property(self, "_base_rotation", Vector3.ZERO, _flip_duration_rot)
|
||||
. set_trans(Tween.TRANS_ELASTIC)
|
||||
. set_ease(Tween.EASE_OUT)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user