Camera for marble game

I am attempting to use the default SmoothFollow camera script on my marble. The marble rolls around just fine, but because the camera is dependent on the marbles y rotation, everything goes nuts.

ideas?

2 Answers

2

Just hook an empty item as a component on your marble that copies position via update routine but not rotation. That way you have effectively made the camera part of an empty component you can manipulate as you wish. You may have other dependancie or problems in the future if you fix rotations now and just stick with glueing to the marble rather than a component that is specifically designed for the camera.

If you use an OOP design you can simply say that all marbles have a camera target empty object with settable overrideable properties.

Doing this you may even be able to swap from marble A to marble B and pan over between them while seeing your old marble run off in the distance. No idea if you want that just seemed fun to mention.

EDIT 09:22 GMT+1 3/31/2011

The object you use to manipulate the camera can have any property you want, or share any property with the marble you want but it will not affect the marble, and more importantly, vice versa this will apply as well.

I do not understand why you would want the marble as a rotation example for the camera.

I assume you want to rotate the camera over the lateral axis x axis (pitch) of the camera so you can look around the surroundings in the far plane or focus on just the marble to determine the size of the field of view for the player.

You summarized it just about right what I tried to explain though.

The whole concept is to be able to program ANYTHING you want in the component object , rather than the marble. You have then succesfully split responsibility between components to avoid overhead and conflict (OOP Design in a nut-shell).

If you can program a rotation behaviour for the camera you can copy that behaviour to an object it "looks at" and call for the camera to lock onto it there.

I may have been wrong in assuming you wanted a theoretical answer though, are you looking for the implementation of the code to use camera rotations using targets instead?

Regardless please let me know how it turns out :) I would love to know ,aswell as being able to improve my Q&A Ability.

So to clarify: 1. Create an empty game object 2. Place the object in center of marble (not parented) and then target the marble so as to copy its position via Update 3. Have the camera smooth follow script target the empty game object 4. Move the ball as normal, the empty moves with the ball without rotating, and the camera fallows the non rotating empty game object. My question here is, if the empty game object never rotates, how will the camera rotate? How can I get a rotation angle based on a previous position? I think this may have some value. What do you think?

Play around with the 'Rotation Damping' property on the script. Setting it to 0 provides no rotation. Then work it up till it meets your needs.