- Home /
Question by
Dris · Feb 13, 2015 at 06:49 AM ·
backgroundscrollingvertical
Vertical camera scrolling fix?
Hello again,
previously I asked a question about how to achieve vertical infinite background scroll; well I was able to come up with the codes below to make the camera scroll down by adding the script to camera but it only scrolls down. I need a fix on this code on how to make it move up. I know its alittle glitch but cant seem to spot it.
Can anyone help?
CODES:
public float speed = 1.1f;
public float acceleration = 0.2f;
public float maxSpeed = 2.5f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
MoveCamera ();
}
void MoveCamera(){
Vector3 temp = transform.position;
float oldY = temp.y;
float newY = temp.y - (speed * Time.deltaTime);
temp.y = Mathf.Clamp (temp.y, oldY, newY);
transform.position = temp;
speed += acceleration * Time.deltaTime;
if (speed > maxSpeed)
speed = maxSpeed;
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613183205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
2D Infinite Vertical Background scrolling 0 Answers
Equally Distributing Light On a Quad Object 2D 2 Answers
I need help with infinite scrolling backgound. 0 Answers
ScrollRect.verticalNormalizedPosition disables scrolling capability. 1 Answer
Large finite background for vertical scroller - best approach? 1 Answer