I have been trying to rotate an object around it’s parent but i cannot get it to work, the orbiting object is a child to the parent but when i run the game the child object does not move at all.
This is my script that is meant to have it rotate around the parent:
using UnityEngine;
using System.Collections;
public class Orbit : MonoBehaviour {
public float rotateSpeed = 5.0f;
public float orbitSpeed = 1.0f;
private Vector3 pos;
void Start(){
//get parent object position
pos = transform.root.gameOject;
}
void update() {
// planet to spin on it's own axis
transform.Rotate (transform.up * rotateSpeed * Time.deltaTime);
// planet to travel along a path that rotates around the sun
transform.RotateAround (pos, Vector3.up, orbitSpeed * Time.deltaTime);
}
}
The script is a component attached to the child object that is meant to rotate.
I have no syntax errors either. Am using the latest version of Unity. What have I got wrong here?