RxGian
November 17, 2019, 3:35pm
1
I want to make simple game like mario bros NES: Mario Bros. - Wikipedia .
I don’t want to allow screen show outside of level and make character loops whenever they reach out of bounding area (they will spawn at right screen if they go outside left and vice versa). Any ideas?
//two empty gameobjects as borders
public Transform leftBorder, rightBorder;
private void Update()
{
if (transform.position.x < leftBorder.transform.position.x)
{
transform.position = new Vector2(rightBorder.transform.position.x, transform.position.y);
}
if(transform.position.x > rightBorder.transform.position.x)
{
transform.position = new Vector2(leftBorder.transform.position.x, transform.position.y);
}
}
RxGian
November 19, 2019, 4:05pm
3
vakabaka:
//two empty gameobjects as borders
public Transform leftBorder, rightBorder;
private void Update()
{
if (transform.position.x < leftBorder.transform.position.x)
{
transform.position = new Vector2(rightBorder.transform.position.x, transform.position.y);
}
if(transform.position.x > rightBorder.transform.position.x)
{
transform.position = new Vector2(leftBorder.transform.position.x, transform.position.y);
}
}
as simple as that? I thought it will be more complex like “globe” scrolling. Anyway I still have no clue with the screen…