Unity Vertical Infinite Scrolling Background + Camera Follow Tutorial in 15 Minutes



Horizontal background not suitable? Implement the vertical scrolling background in a different way within 15 minutes.

➥➥➥ RELATED TUTORIALS ➥➥➥
Scrolling Background ⇢

➥➥➥ MORE TUTORIALS ➥➥➥
Victory Effect ⇢
Squash And Stretch ⇢
Pool Manager ⇢
Leaderboard ⇢
In-App Purchase ⇢

➥➥➥ SUBSCRIBE FOR MORE VIDEOS ➥➥➥
Never miss a video about Unity features.
Subscribe ⇢

#unity #scrollingbackground #unitytutorial

Nguồn: https://newblurayrelease.com/

Xem thêm bài viết khác: https://newblurayrelease.com/game/

  • Thanks so much for this man, really simple and easy to understand.

    Hafiz Bhuyan July 26, 2020 9:57 pm Reply
  • How do I add random platforms to this? I'm struggling so much rn :((

    StejoThePisto July 26, 2020 9:57 pm Reply
  • 🙂 thanks

    DAMIEN PARISH July 26, 2020 9:57 pm Reply
  • 1.5x speed for faster learning

    CJ Rhone July 26, 2020 9:57 pm Reply
  • this would be useful information if i could understand it

    benjams July 26, 2020 9:57 pm Reply
  • if u attach any other collider inside the background on different layer even on the player it will not work

    harsh dhillon July 26, 2020 9:57 pm Reply
  • using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;

    public class FollowCamera : MonoBehaviour

    {

    public Transform target;

    public Transform BG1;

    public Transform BG2;

    private float size;

    private Vector3 cameraTargetPos = new Vector3();

    private Vector3 BG1TargetPos = new Vector3();

    private Vector3 BG2TargetPos = new Vector3();

    // Start is called before the first frame update

    void Start()

    {

    size = BG1.GetComponent<BoxCollider2D>().size.y;

    size = BG2.GetComponent<BoxCollider2D>().size.y;

    }

    // Update is called once per frame

    void FixedUpdate()

    {

    Vector3 targetPos = SetPos(cameraTargetPos,target.position.x,target.position.y,transform.position.z);

    transform.position = Vector3.Lerp(transform.position,targetPos,0.2f);

    if (transform.position.y >= BG2.position.y)

    {

    BG1.position = SetPos(BG1TargetPos ,BG1.position.x,BG2.position.y + size,BG1.position.z);

    SwitchingBG();

    }

    if (transform.position.y <= BG1.position.y)

    {

    BG1.position = SetPos(BG2TargetPos,BG1.position.x,BG2.position.y – size,BG1.position.z);

    SwitchingBG();

    }

    }

    private void SwitchingBG()

    {

    Transform temp = BG1;

    BG1 = BG2;

    BG2 = temp;

    }

    private Vector3 SetPos(Vector3 pos,float x,float y , float z)

    {

    pos.x = x;

    pos.y = y;

    pos.z = z;

    return pos;

    }

    }

    harsh dhillon July 26, 2020 9:57 pm Reply
  • nice

    Julian Kühn July 26, 2020 9:57 pm Reply
  • But this for same type of 2 bg , what if we have more than 2 i.e. ore 3-4 scene how to make them repeat

    harsh dhillon July 26, 2020 9:57 pm Reply
  • Hehe boi

    Fernando Ruiz Gimenez July 26, 2020 9:57 pm Reply
  • Pls start series with prefab and pun2 thanks

    MerAndroid July 26, 2020 9:57 pm Reply
  • very helpful, thank you.

    Abra Dev July 26, 2020 9:57 pm Reply

Leave a Reply

Your email address will not be published. Required fields are marked *