Hi im looking that the camera follor my character only in Y but in my stage my character is moving in X, Y and Z.
im using this code for do this but im having a problem with the camera position.
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);
}
}
when i play my demo the camera started in other Y position.
My character is in Y 2.7 and my camera Y 5.5
I think that this code is transforming my Camera Y in the Character Y position.
any help? thanks!
You can hit the button with a bunch of zeroes on it to properly format your code... I did it for you this time.
– e-bonneville