I’m using an orthographic camera which I control left and right movement like such:
void Update () {
//amount to move
float amountToMove = Input.GetAxisRaw("Horizontal") * CameraSpeed * Time.deltaTime;
//move the camera
transform.Translate(Vector3.right * amountToMove);
}
I need to restrict the camera so it cannot move past certain point of the x axis. I tried using clampf but I can’t seem to get it to work. Any suggestions?
Whoops, I forgot my Mathf.Clamp syntax! Should've checked the documentation first... Fixed!
– syclamothVery long after this post, but.......this worked great for my overhead tracking cam of a golf ball on a fairway - only thing is - its a little harsh when it picks up the ball and starts tracking it. Anyway of smoothing this out? Lerp or something? But how do I implement it in this as an example: Mathf.Clamp(transform.position.x, minimum, maximum), Thanks.
– Korpers