im trying to modify the sideScrollSetup scene in the Standard Assets(mobile) package, the SmoothFollow2D script.
I want the camera to stop following the player when a certain point is reached and vice versa. The if statement i added works with one little problem. The camera stops fine, and when u move back from that certain point the camera follows the player again however its not a smooth transition. It sort of bounces once.
thanks
var target : Transform;
var smoothTime = 0.3;
private var thisTransform : Transform;
private var velocity : Vector2;
function Start() {
thisTransform = transform;
}
function Update() {
thisTransform.position.y = Mathf.SmoothDamp( thisTransform.position.y,
target.position.y, velocity.y, smoothTime);
**if(target.position.x < 19 && target.position.x > -15) {**
thisTransform.position.x = Mathf.SmoothDamp( thisTransform.position.x,
target.position.x, velocity.x, smoothTime);
}
}
Hello. I can show you what I made, because i had the same problem.
With this script, the camera will follow your player, but if he is
X < 4 and X > 11
and
Z < 1 and Z > 8