Hi guys, finally im starting a personal project out of the work
Im 3D designer working in video game industry (3d modeling and animation) and im programing a bit.
All is going great very easy, unity is great! i love it.
My project is a scrolling game like the classic Final fight, The Simpsons, Captan Commando, TMNT, etc.
The characters move in the axis X and Z and can jump (Y) but the camera only use axis X ( scroll ).
I tried the SmoothFollow script but the camera move behind my character and is not working like i want.
I tried put the camera inside my character but obviously when my character walk in axis Z the camera too.
So i found this script in Answer Unity Site.
var dampTime : float = 0.3; //offset from the viewport center to fix damping
private var velocity = Vector3.zero;
var target : Transform;
function Update() {
if(target) {
var point : Vector3 = camera.WorldToViewportPoint(target.position);
var delta : Vector3 = target.position - camera.ViewportToWorldPoint(Vector3(0.5, 0.5, point.z));
var destination : Vector3 = transform.position + delta;
transform.position = Vector3.SmoothDamp(transform.position, destination, velocity, dampTime);
}
}
Is following well in the axis X and Z but the camera position is wrong in the axis Y and when my character jump the camera follow him and i don’t want it.
here a link with a test build
http://badmouse.a.lisonal.com/unity3d/
The camera move down automatically and i don’ understand the reason.
checking the position Y of my camera and character i found that the Y position of my Character is 2.8 and the Y position of my Camera is 5.3.
so the camera isn’t follow well my character. the camera move down to 2.8 (character Y position)
how i can fix it?
Here a pic how it looks in Unity
And Here how it look after compile.
Thanks for the help