refactor player transforming

This commit is contained in:
Teatov 2025-08-02 23:03:26 +10:00
parent 6f399db783
commit 53fb1c6958
2 changed files with 23 additions and 11 deletions

View File

@ -3,14 +3,15 @@
[ext_resource type="Script" uid="uid://dmfdlb4ae57qv" path="res://scripts/player.gd" id="1_3vyb7"]
[sub_resource type="BoxMesh" id="BoxMesh_u8vuu"]
size = Vector3(0.6, 0.6, 0.6)
[node name="Player" type="Node3D"]
script = ExtResource("1_3vyb7")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0)
mesh = SubResource("BoxMesh_u8vuu")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(0.310767, 0, 0, 0, 0.310767, 0, 0, 0, 0.310767, 0, 0.5, 0.63)
transform = Transform3D(0.310767, 0, 0, 0, 0.310767, 0, 0, 0, 0.310767, 0, 0.394854, 0.356113)
mesh = SubResource("BoxMesh_u8vuu")

View File

@ -21,15 +21,26 @@ func _ready() -> void:
func _process(_delta: float) -> void:
if _current_key:
global_position = _current_key.player_pos_marker.global_position
var rotation_translate := (
_current_key.get_default_transform().inverse()
* _current_key.player_pos_marker.global_transform
)
global_rotation = (
(_rotation * (rotation_translate.basis.get_rotation_quaternion()))
. get_euler()
)
global_position = _animate_position()
global_rotation = _animate_rotation()
#endregion
#region animation
func _animate_position() -> Vector3:
return _current_key.player_pos_marker.global_position
func _animate_rotation() -> Vector3:
var rotation_translate := (
_current_key.get_default_transform().inverse()
* _current_key.player_pos_marker.global_transform
)
return (
(_rotation * (rotation_translate.basis.get_rotation_quaternion())).get_euler()
)
#endregion