camera orbit like star defence

Hi folks!

How Can I do a mouse orbit like this?

http://www.youtube.com/watch?v=OouBzirUZww&feature=related

The mouse orbit in the standard assets is limited :|, when I'm at the top of the sphere the camera spins!

Tnx a lot :)

Yeah, I could understand you'd have issues using mouse orbit. I suggest you combine Transform.LookAt( Vector3 ), to keep the camera looking at your target, with regular movement scripting.

In untested C#

using UnityEngine;
using System.Collections;

public class FreeformMouseOrbit : MonoBehaviour
{
    public Transform target;
    public float desiredDistance = 10.0f;

    // should be used for all camera-movement scripts
    public void LateUpdate()
    {
        // focus camera on target
        transform.LookAt( target.position );

        // ... use science to figure out direction of travel relative to camera (up, right, down, left, or a combination)
        Vector3 movementVector = science;

        // move in that direction
        transform.position += movementVector;

        // if you have problems with zoom, move the camera so that it's the appropriate distance from the target
        float actualDistance = Vector3.Distance( transform.position, target.position );
        if( !Mathf.Approximately( desiredDistance, actualDistance ) )
        {
            Vector3.MoveTowards( transform.position, target.position, Mathf.Abs( actualDistance - desiredDistance ) );
        }
    }
}

Now in untested JS:

// FreeformMouseOrbit.js
public var target : Transform;
public var desiredDistance : float = 10.0;

// should be used for all camera-movement scripts
public function LateUpdate() : void
{
    // focus camera on target
    transform.LookAt( target.position );

    // ... use science to figure out direction of travel relative to camera (up, right, down, left, or a combination)
    var movementVector : Vector3 = science;

    // move in that direction
    transform.position += movementVector;

    // if you have problems with zoom, move the camera so that it's the appropriate distance from the target
    var actualDistance : float = Vector3.Distance( transform.position, target.position );
    if( !Mathf.Approximately( desiredDistance, actualDistance ) )
    {
        Vector3.MoveTowards( transform.position, target.position, Mathf.Abs( actualDistance - desiredDistance ) );
    }
}