Hello everyone,
I need help with a camera script I’m currently working with.
Here is the script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SecurityCameraControl : MonoBehaviour
{
//public float speedH = 20.0f; Script for a First Person Camera
public float rightSpeed = 20.0f;
public float leftSpeed = -20.0f;
//public float rotationY = 0.0f; Script for a First Person Camera
void Update()
{
//rotationY += speedH * Input.GetAxis("Mouse X"); Script for a First Person Camera
//transform.eulerAngles = new Vector3(0, rotationY, 0); Script for a First Person Camera
//rotationY = Mathf.Clamp(rotationY, 50f, 130f); Script for a First Person Camera
//EdgeScrolling
float edgeSize = 40f;
if (Input.mousePosition.x > Screen.width - edgeSize)
{
//EdgeRight
transform.RotateAround(this.transform.position, Vector3.up, rightSpeed * Time.deltaTime);
}
if (Input.mousePosition.x < edgeSize)
{
//EdgeRight
transform.RotateAround(this.transform.position, Vector3.up, leftSpeed * Time.deltaTime);
}
}
}
This is the script and I want to implement a limit to the camera so that I can’t rotate 360°.
I already tried to do this in line 20 and it worked, but now I want to transfer that into my real script.
If you need more information please ask me.
Thanks in advance,
Max