Next, in order to enhance the game experience, we will add a food rotation function.
Add a new script file to food under assets and name it food_rotation:
The scripting code is as follows:
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);
}
}
The finished effect is as follows: