【发布时间】:2021-10-27 15:07:29
【问题描述】:
我正在尝试为基于this 视频的模拟游戏创建 3D 相机,该视频展示了如何在 Unity 中进行操作。在将代码转换为 GDScript 时,我遇到了一个问题:我无法让相机旋转。 这是我对视频中脚本旋转部分的 GDScript 解释(时间戳:8:50-10:10):
export(float) var rotation_amount = 1
export(Quat) var new_rotation
func _ready():
new_rotation = rotation
func _process(delta):
handle_movement_input(delta)
func handle_movement_input(delta):
if(Input.is_action_pressed("cam_rotate_left")):
new_rotation *= Quat(Vector3.UP * rotation_amount).get_euler()
if(Input.is_action_pressed("cam_rotate_right")):
new_rotation *= Quat(Vector3.UP * -rotation_amount).get_euler()
rotation = rotation.linear_interpolate(new_rotation, delta * movement_time)
【问题讨论】:
标签: 3d quaternions godot euler-angles