How to control radius and speed separately (quaternions)

Hi
i have been playing around with the quaternions tutorial.
http://unity3d.com/learn/tutorials/modules/intermediate/scripting/quaternions
The gravity script( Added below )
How would I go about controlling the radius from the look at object and the speed of the rotation separately?
I would like to change both values dynamically , right now I can’t get one to work with affecting the other (radius|speed)

Any suggestions ?

Update function form the link :

void Update () 
    {
        Vector3 relativePos = (target.position + new Vector3(0, 1.5f, 0)) - transform.position;
        Quaternion rotation = Quaternion.LookRotation(relativePos);
        
        Quaternion current = transform.localRotation;
        
        transform.localRotation = Quaternion.Slerp(current, rotation, Time.deltaTime);
        transform.Translate(0, 0, 3 * Time.deltaTime);
    }

I tried it out myself and I also had a tough time finding a way to Increase / Decrease Radius without changing the Speed.

I did manage to simply increase the Speed without changing the radius, which wasn’t too difficult.
I don’t know if it helps, but you’ll be a step closer if you didn’t have this yet :slight_smile:

using UnityEngine;
using System.Collections;

public class GravityScript : MonoBehaviour
{
    public Transform target;
    public float SlerpSpeed         = 3f;   // Increasing SlerpSpeed,       Orbit Radius Decreased, Orbit Duration Decreased
    public float TranslationSpeed   = 3f;   // Increasing TranslationSpeed, Orbit Radius Increased, Orbit Duration Unchanged
    public float OrbitSpeed         = 5f;   // Increasing OrbitSpeed,       Orbit Radius Unchanged, Orbit Duration Increased

    void Update()
    {
        Vector3 relativePos = target.position - transform.position;
        Quaternion rotation = Quaternion.LookRotation(relativePos);

        Quaternion current = transform.localRotation;

        transform.localRotation = Quaternion.Slerp(current, rotation, SlerpSpeed * OrbitSpeed * Time.deltaTime);
        transform.Translate(0, 0, TranslationSpeed * OrbitSpeed * Time.deltaTime);
    }
}

Added some comments too, to maybe get better insight, good luck! :slight_smile: