private float FollowPosx,FollowPosy;
private float moveAmount=5; //控制镜头的移动速度
// Update is called once per frame
void Update()
{
if (Input.mousePosition.y > Screen.height * 0.9)//如果鼠标位置在顶部,就向上移动
{
FollowPosy += moveAmount * Time.deltaTime;
}
if (Input.mousePosition.y < Screen.height * 0.1)//如果鼠标位置在底部,就向下移动
{
FollowPosy -= moveAmount * Time.deltaTime;
}
if (Input.mousePosition.x > Screen.width * 0.9)//如果鼠标位置在右侧,就向右移动
{
FollowPosx += moveAmount * Time.deltaTime;
}
if (Input.mousePosition.x < Screen.width * 0.1) //如果鼠标位置在左侧,就向左移动
{
FollowPosx -= moveAmount * Time.deltaTime;
}