【发布时间】:2020-05-28 14:45:59
【问题描述】:
我在 c# 中为 Unity 编写了一个简单的脚本,用于在图像目标上方制作一个类似于球体轨道 (0,0,0) 的 3D 对象。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class Orbit : MonoBehaviour
{
float angles;
float radiuss;
float angleSpeed;
// Start is called before the first frame update
void Start()
{
angles = 0;
radiuss = 0.2f;
angleSpeed = 1;
}
// Update is called once per frame
void Update()
{
angles += Time.deltaTime * angleSpeed;
float x = radiuss * Mathf.Cos(Mathf.Deg2Rad * angles);
float z = radiuss * Mathf.Sin(Mathf.Deg2Rad * angles);
float y = 1*0;
transform.position = new Vector3(x, y, z);
}
}
如果不用于 Vuforia,该脚本可以正常工作,但是当我将它添加到 Vuforia 的对象时,它的行为很奇怪,并且不遵循脚本描述的路径。
请帮忙。
【问题讨论】: