private float movementSpeed = 2f;
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
transform.position = transform.position - new Vector3(horizontalInput * movementSpeed * Time.deltaTime, 0, verticalInput *
movementSpeed * Time.deltaTime);
}
private void Update()
{
float limit_X_min = -1000f; //Лимит
float limit_X_max = 1000f; //Лимит
float camera_X = privezat_k.transform.position.x;
if (camera_X < limit_X_min) camera_X = limit_X_min;
if (camera_X > limit_X_max) camera_X = limit_X_max;
transform.position = new Vector3(camera_X, 0f, -10f);
}
private float movementSpeed = 2f;
public Rect limits = new Rect(0,0,20,20);
Vector2 newPosV2 = new Vector2();
Vector3 newPosV3 = new Vector3();
void Update1()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
newPosV3 = transform.position - new Vector3(horizontalInput * movementSpeed * Time.deltaTime, 0,
verticalInput * movementSpeed * Time.deltaTime);
newPosV2.Set(newPosV3.x, newPosV3.z);
if (limits.Contains(newPosV2)) transform.position = newPosV3;
}