简体   繁体   English

Unity:如何旋转这些生成的障碍物?

[英]Unity: How can I rotate these spawned obstacles?

I have meteorites as obstacles that I want to be rotating.我有陨石作为我想要旋转的障碍物。

This is the value of the meteorites that I want to change during the game:这是我想在游戏中改变的陨石数值:

回转

Here is a picture of how the meteorites look when the game is running:这是游戏运行时陨石的外观图片:

陨石

PS: I can increase the value on my own. PS:我可以自己增加价值。

You can try this out:你可以试试这个:

using UnityEngine;

public class Rotator : MonoBehaviour
{
    public float rotSpeed;

    void Update()
    {
        transform.Rotate(new Vector3(0, 0, rotSpeed));
    }
}

attach this to one of your meteorites and set a rotation speed in the rotSpeed value in the editor将此附加到您的一颗陨石上,并在编辑器的 rotSpeed 值中设置旋转速度

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

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