void Update() { age += Time.deltaTime; Vector3 offset = Powers_AnimMath.SpotOnCircleXZ(radius, age); transform.position = target.position + offset; }
void CalculateOrbit() { //checks if transform has been added. if not, script can act as a simple rotation script if (center != null) { //Getting the orbit position orbitAge += ((Time.deltaTime * timeManager.time) / orbitTime); Vector3 offset = Powers_AnimMath.SpotOnCircleXZ(orbitRadius, orbitAge); //Getting the orbital tilt, using the center's rotation as a base Quaternion orbitTiltFactor = Quaternion.Euler(0, 0, orbitTilt); offset = orbitTiltFactor * offset; transform.position = center.position + offset; } //Getting the orbit rotation rotationAge += ((Time.deltaTime * timeManager.time) / rotationTime) * 60; transform.eulerAngles = new Vector3(0, rotationAge, transform.rotation.z); //Apply the axial tilt using world space transform.Rotate(axialTilt, 0, 0, Space.World); }