Hey guys, so I started a new project to test some no clipping stuff, and so far its working pretty well.
Currently this script is just attached to a cube in the scene. It works pretty well for not looking for much help so far.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NoClip : MonoBehaviour
{
public float speed_normal = 5f;
public float rotX;
public float rotY;
public float camSensitivity = 5f;
void Update()
{
rotX += Input.GetAxis("Mouse X") * (camSensitivity * Time.deltaTime);
rotY += Input.GetAxis("Mouse Y") * (camSensitivity * Time.deltaTime);
rotY = Mathf.Clamp (rotY, -90, 90);
transform.localRotation = Quaternion.AngleAxis(rotX, Vector3.up);
transform.localRotation *= Quaternion.AngleAxis(rotY, Vector3.left);
transform.position += transform.forward.normalized * speed_normal * Input.GetAxis ("Vertical") * Time.deltaTime;
transform.position += transform.right.normalized * speed_normal * Input.GetAxis ("Horizontal") * Time.deltaTime;
}
}
I am running into a few issues however that are very minor.
EDIT: First issue was a framerate issue with laptops performance. Just need assistance with the diagonal speed!
The second issue is diagonal speed. It seems to go faster while moving diagonal. I did however add “.normalized” to this part, but I cant tell due to laptops performance whether or not it actually helped or not.
transform.position += transform.forward.normalized * speed_normal * Input.GetAxis ("Vertical") * Time.deltaTime;
transform.position += transform.right.normalized * speed_normal * Input.GetAxis ("Horizontal") * Time.deltaTime;
other than that, all is good and it works as expected.
Thanks for the help!