【发布时间】:2022-12-11 03:41:36
【问题描述】:
我有 3d 球类游戏。小球继续前进。当按下左或右旋转键时,它会向该方向移动与按下的量一样多的量。球运动体和使用速度。当道路笔直时,一切都完美无缺
我很困惑从直线路径切换到曲线路径时我应该改变速度什么。任何帮助表示赞赏
寻求有关矢量和速度的帮助
【问题讨论】:
-
我不确定我是否理解,但如果这是我的想法,你将需要一个流场。
-
您应该分享与球的运动相关的代码。
我有 3d 球类游戏。小球继续前进。当按下左或右旋转键时,它会向该方向移动与按下的量一样多的量。球运动体和使用速度。当道路笔直时,一切都完美无缺
我很困惑从直线路径切换到曲线路径时我应该改变速度什么。任何帮助表示赞赏
寻求有关矢量和速度的帮助
【问题讨论】:
func _physics_process(delta):
velocity= direction* delta * max_speed*10
if translation.distance_to(points[current_point].translation) < 3:
if current_point +1 == len(points):
return
else:
current_point += 1
rotate_y(-90)
camera.rotate_y(-90)
camera.offset=Vector3(-10,5,0)
direction = (points[current_point].translation - translation).normalized()
if Input.is_action_pressed("ui_left"):
velocity.x = lerp(velocity.x, -max_speed, 0.1) ##### Here #####
rotate_z(deg2rad(max_speed/5))
if Input.is_action_pressed("ui_right"):
velocity.x = lerp(velocity.x, max_speed, 0.1) ##### Here #####
rotate_z(deg2rad(-max_speed/5))
if !is_on_floor():
velocity.y -= max_speed/12
move_and_slide(velocity)
【讨论】: