物体自动绕XYZ旋转

可自行修改绕不同轴进行旋转

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

public class Stateother : MonoBehaviour
{

   private GameObject Player;
    private GameObject Food;
    private int time = 1;
private int speed=1;//可修改
    // Start is called before the first frame update
    void Start()
    {
        Player = GameObject.Find("player");
        Food = GameObject.Find("littlefood1");
    }

    // Update is called once per frame
    void Update()
    {
         time++;
      Food.transform.rotation = Quaternion.Euler(0, time*speed, 0);
    }
}

猜你喜欢

转载自blog.csdn.net/qq_52058429/article/details/126652681
xyz