【问题标题】:How to tween Linear Velocity in rigidbody2d godot如何在rigidbody2d godot中补间线速度
【发布时间】:2022-01-18 19:30:06
【问题描述】:

尝试此代码,但它沿对角线移动对象(右下)

func _ready():
    tween = get_node("Tween")
    pass

func _physics_process(_delta):
    tween.interpolate_property(self,"linear_velocity",null,Vector2(0,0.1),1,Tween.TRANS_LINEAR,Tween.EASE_IN_OUT)
    tween.start()
    pass```

【问题讨论】:

  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

标签: godot tween


【解决方案1】:

很难弄清楚您要完成什么以及使用哪种类型的节点,但是您可以尝试以下方法:

var TARGET_VELOCITY = Vector2(0,0.1)
var LERP_SPEED = 1

func _physics_process(_delta):
    var newVelocity = self.linear_velocity.linear_interpolate(TARGET_VELOCITY , delta * LERP_SPEED)
    self.linear_velocity = newVelocity 

来自插值教程: https://docs.godotengine.org/en/stable/tutorials/math/interpolation.html

【讨论】:

  • 对不起,我的价值太小了tween.interpolate_property(self,"linear_velocity",null,Vector2(100,0),1,Tween.TRANS_LINEAR,Tween.EASE_IN_OUT)& godot 使用我的旧代码来自 vs 代码,即使在保存后这就是它对角移动的原因
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-03
  • 2021-12-12
  • 2022-12-11
  • 1970-01-01
  • 2021-10-22
相关资源
最近更新 更多