So I got the spiraling upwards script going, it’s working fine. Problem is, I can’t get it to specifically spiral around another object. It rather “meets” the object (I say “meet” and not “collide” because I don’t have a collider component) if my “initialoffset” is 0. I added “InitialOffset” hoping it would help solve, but it doesn’t really seem to help a lot. It mostly just spirals around at the vicinity of the other object, depending on the figures for AngleSpeed and SpiralRadius. See code, it’s pretty self-explanatory.
using UnityEngine;
using System.Collections;
public class SpiralingCamera : MonoBehaviour {
public Vector3 pos;
public GameObject CenterOfAttetion; //the target the camera will always follow around, apply in Insepctor
public float SpiralRadius;
public float VerticalSpeed;
public float RadianAngle;
public float AngleSpeed;
public float InitialOffset;
void Start ()
{
pos = CenterOfAttetion.transform.position;
this.transform.position = CenterOfAttetion.transform.position;
transform.Translate(Vector3.forward * InitialOffset, Space.World);
}
void Update ()
{
RadianAngle += AngleSpeed;
transform.Translate(Vector3.forward * SpiralRadius * Mathf.Cos (RadianAngle), Space.World);
transform.Translate(Vector3.right * SpiralRadius * Mathf.Sin (RadianAngle), Space.World);
transform.Translate(Vector3.up * VerticalSpeed, Space.World);
}
}