如何使物体像愤怒的小鸟 2 中的小鸟一样面向它移动的方向?



我正在使用Unity2D。我想让我的物体面向它移动的方向。当对象向左移动时,它将面向左侧。当物体向上移动时,它将朝上方向。

我希望它像愤怒的小鸟2在飞行时的鸟一样。

不是 2D 专家,但你可以做这样的事情

private Vector3 lastFramePos;
private void Update()
{
    // get the direction
    var direction = (transfor.position - lastFramePos).normalized;
    // set the look direction depending on your needs e.g.
    transform.right = direction;
    // don't forget to update the lastFramePos
    lastFramePos = transform.position;
}

注意:在智能手机上输入,所以没有保证,但我希望这个想法清楚

最新更新