Hello I am new to unity and have very little coding experience so please bare with me, I need a basic 2d sidescrolling camera that doesn’t follow every jump of the character but would follow if the character was on a higher platform.
Any help would be greatly appreciated.
That’s one is easy. Don’t update Y position of camera all the time, update it only when player’s on ground. In pseudocode:
//updating position
Vector3 pos = new Vector3();
pos.x = player.transform.position.x; //'player' is public GameObject variable
if (onGround){
pos.y = player.transform.position.y; //'player' is public GameObject variable
} else {
pos.y = this.transform.position.y;
}
pos.z = this.transform.position.z;
this.transform.position = pos;
But you need to be aware that this kind of scrolling is annoying from player’s perspective and can be major annoyance, especially in shooting games (you won’t see where you’re jumping until you land).