少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using UnityEngine;
using System.Collections;
 
public class CirclePathController : MonoBehaviour
{
    public Vector3 center;
    public float radius;
    public int speed;
    private int degree;
 
    void Start()
    {
        InvokeRepeating("TestInvoke", 0, 0.03f);
    }
 
    void Update()
    {
    }
 
    void TestInvoke()
    {
        UnityEngine.Profiling.Profiler.BeginSample("TestInvoke");
        int _realIndex = Mathf.Abs(degree % 360);
 
        float _x = center.x + GeometryConstant.COS_ANGLE_VALUE[_realIndex] * radius;
        float _z = center.z + GeometryConstant.SIN_ANGLE_VALUE[_realIndex] * radius;
 
        transform.position = new Vector3(_x, center.y, _z);
 
        degree += speed;
 
        if (degree > 359)
            degree = 0;
        else if (degree < 0)
            degree = 359;
        UnityEngine.Profiling.Profiler.EndSample();
    }
}