围绕圆心形旋转

实现了围绕圆心旋转功能

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

public class Roation : MonoBehaviour {
    public float range = 10;
	void Update () {
        float x = Mathf.Sin(Mathf.PI * 2 * Time.time * 0.1f) * range;
        float z = Mathf.Cos(Mathf.PI * 2 * Time.time * 0.1f) * range;
        Vector3 curPosition = Vector3.zero;
        curPosition.x += x;
        curPosition.z += z;
        this.transform.position = curPosition;
    }
}

猜你喜欢

转载自my.oschina.net/u/698044/blog/1812736