hello, I’m a beginner and I followed a tutorial to make camera boundaries so the blue background of the unity editor doesn’t appear, and it works just fine. However I have two issues, the first one is that the camera boundaries (the coordinates) keep adjusting on their own when I open the maximized game view or change the scene window size. How do I know what size will be suitable when I build the game?
The second issue is, right after I wrote the boundaries script the player started freaking out and shaking while moving (I can take a video of this if you need).
A short video or even a picture and code might help. It is a little difficult to understand the issue as described. Please use the code tags if you paste code here.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class camerabounds : MonoBehaviour {
public Transform target;
public Vector2 minipos;
public Vector2 maxpos;
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
transform.position = new Vector3(Mathf.Clamp(target.position.x, minipos.x, maxpos.x),
Mathf.Clamp(target.position.y, minipos.y, maxpos.y),
transform.position.z);
}
}
The camerabounds script is placed on the main camera, correct? Also make sure that the player is not a child of the main camera, and that the main camera is not a child of the player.
How are you setting the values of minipos and maxpos - if you are typing out the values you want in the inspector, then they shouldn’t be changing as you describe and especially not when changing the size of the scene window.
A short video of this as well as the shaking behaviour of the player would help a lot in narrowing this down.