unity开发案例RollABall(6)之控制游戏对象旋转

接下来,为了增强游戏的体验性,我们会设置增加一个食物旋转的功能。

给assets下面的food添加一个新的脚本文件,并且命名为food_rotation:

脚本编写代码如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class food_rotation : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(Vector3.up*6);
    }
}

完成效果如下:


 

猜你喜欢

转载自blog.csdn.net/qq_51196701/article/details/123023719