欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

内部实战揭秘#愚公星球2022二月特辑:U3D全栈实战课008 - 制作星系级别的游戏场景指南

最编程 2024-02-19 14:00:12
...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Rotate this object around center target object
/// </summary>
///
public class PlanetRotate : MonoBehaviour
{
[SerializeField,Tooltip("围绕的中心点")]
public GameObject centerTarget;
public float angleDegreeSpeed = 1;
public float rotateLocalSpeed = 15;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
this.transform.Rotate(Vector3.up, rotateLocalSpeed*Time.deltaTime);
if (centerTarget!=null)
{
//this.transform.RotateAroundLocal
this.transform.RotateAround(centerTarget.transform.position,Vector3.up, angleDegreeSpeed*Time.deltaTime);
}
}
}