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.
How do I add random platforms to this? I'm struggling so much rn :((
🙂 thanks
1.5x speed for faster learning
this would be useful information if i could understand it
if u attach any other collider inside the background on different layer even on the player it will not work
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;
}
}
nice
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
Hehe boi
Pls start series with prefab and pun2 thanks
very helpful, thank you.