Hey, can someone help me with this? So I’m making an RTS game and I’m making the camera panning thing. I have a problem with the edge panning the Y is working but the X is not. The arrows are working perfect but the edge panning of the X is messed up.
This is the code that i use.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseMovementCamera : MonoBehaviour {
public float panSpeed = 20f;
public float panBorderThicknes = 15f;
void Update() {
Vector3 pos = transform.position;
if (Input.mousePosition.y >= Screen.height - panBorderThicknes)
{
pos.z += panSpeed * Time.deltaTime;
}
if (Input.mousePosition.y <= panBorderThicknes)
{
pos.z -= panSpeed * Time.deltaTime;
}
if (Input.mousePosition.x >= Screen.width - panBorderThicknes)
{
pos.x += panSpeed * Time.deltaTime;
}
if (Input.mousePosition.x <= panBorderThicknes)
{
pos.x -= panSpeed * Time.deltaTime;
}
transform.position = pos;
}
}