refactor player transforming
This commit is contained in:
parent
6f399db783
commit
53fb1c6958
@ -3,14 +3,15 @@
|
|||||||
[ext_resource type="Script" uid="uid://dmfdlb4ae57qv" path="res://scripts/player.gd" id="1_3vyb7"]
|
[ext_resource type="Script" uid="uid://dmfdlb4ae57qv" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_u8vuu"]
|
[sub_resource type="BoxMesh" id="BoxMesh_u8vuu"]
|
||||||
|
size = Vector3(0.6, 0.6, 0.6)
|
||||||
|
|
||||||
[node name="Player" type="Node3D"]
|
[node name="Player" type="Node3D"]
|
||||||
script = ExtResource("1_3vyb7")
|
script = ExtResource("1_3vyb7")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[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")
|
mesh = SubResource("BoxMesh_u8vuu")
|
||||||
|
|
||||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
|
[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")
|
mesh = SubResource("BoxMesh_u8vuu")
|
||||||
|
|||||||
@ -21,15 +21,26 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if _current_key:
|
if _current_key:
|
||||||
global_position = _current_key.player_pos_marker.global_position
|
global_position = _animate_position()
|
||||||
var rotation_translate := (
|
global_rotation = _animate_rotation()
|
||||||
_current_key.get_default_transform().inverse()
|
|
||||||
* _current_key.player_pos_marker.global_transform
|
|
||||||
)
|
#endregion
|
||||||
global_rotation = (
|
|
||||||
(_rotation * (rotation_translate.basis.get_rotation_quaternion()))
|
|
||||||
. get_euler()
|
#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
|
#endregion
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user