繁体   English   中英

如何使物体像愤怒的小鸟2上的小鸟一样面对运动的方向?

[英]How can I make an object to face the direction it's moving like the birds at angry birds 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;
}

注意:在智能手机上键入内容,因此没有保修,但我希望这个想法能弄清楚

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM