创建俩个sphere,然后创建一个脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class zhuan : MonoBehaviour
{
///
/// 这是子物体公转的对象
///
public Transform m_sphere;
///
/// 用于自转的子物体
///
public Transform m_sphereA;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//自转
m_sphereA.Rotate(Vector3.up, Space.Self);
//公转
m_sphereA.RotateAround(m_sphere.position, m_sphere.up, Time.deltaTime * 50);//这是用来控制旋转的速度
}
}
创建好脚本之后在创建一个空物体,将代码拖进去,然后将刚刚创建的俩个用于旋转的物体拖入
然后运行即可



