Camera Following Roller-ball-tutorial

I was trying to attach a camera to the roller-ball tutorial for it to follow it. I wanted the camera to follow directly above the ball looking down on it. I tried two different scripts (one on wiki) and the smooth follow in the standard assets…but in both cases the camera tries to follow the ball (including its rotation) which results in the camera tumbling with the ball as it rolls or following it…but spinning around it as it rotates. I just want it to be above it…looking down and moving with it as it as it rolls. Any help would be great.

Thanks

I’m not sure how to use the program yet, but I started a tutorial, and you know how you can group things under a parent? Could you have the ball a child, and it rotates, but the camera follows the parent of the ball, which moves but doesn’t rotate?

I actually tried that and it didn’t seem to work. I created an empty object…parented it with the ball… and then told the smooth follow script to look at the dummy object (that now has the ball as a child object)…the camera does not follow…even though I can see the parent object moving along with the ball…the camera just sits still. Strange.

I’ve been trying to do the same thing… I’ve asked similar questions with no answers. It would be cool to have a tutorial about doing this. If I figure it out I’ll post it.

Place and rotate the camera how you want it in the inspector and place this code in it:

var relativeVector : Vector3;
var targeti : Transform;

function Start()
{
   relativeVector = targeti.position - transform.position;
}

function Update()
{
   transform.position = targeti.position + relativeVector;
}

This will only work if you never want to move the camera relative to the target. It’s simply a fixed camera relative to the target.

I found a forum thread that got me going in the right direction.

http://forum.unity3d.com/viewtopic.php?t=10282

Download the unity package in this thread.

Kudos to drag0nsphere

Here is my solution, it worked veery well!
Public GameObject ball;
private Vector3 pos;

void start () {
pos = new Vector3 (0,15,0);
}

void update () {
this.transform.position = ball.transform.position + pos;
}

It is in C#, hope it helps

Is there an easier way? Because i am new to unity and i am using unity 2017

also @enrique0 your code is outdated now and is classified as an error. At least in my version