接下来,为了增强游戏的体验性,我们会设置增加一个食物旋转的功能。
给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);
}
}
完成效果如下: