I have written a simple c# script for Unity+Vuforia. I want to create a simple sample project where an object like a sphere is revolving (orbiting) origin (0,0,0) above image target.
The code I have written is here
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 = 0;
transform.position = new Vector3(x, y, z);
}
}
It works perfectly fine if I am not using it with Vuforia, but when I attach this script as component to an object in Vuforia, it does not work and acts weird.
These are the configurations and hierarchy
Please help me out, I tried a lot of things.