Code Snippet
In The Empty: Lost Footage » Devlog
Hi! Here's a snippet of code to show you that there is NO copy and paste f<spoiler>ri</spoiler>kery going on here!
In The Empty: Lost Footage
Lost Footage is a concept/gameplay demo.
Status | Prototype |
Author | BioTechGames |
Genre | Survival |
Tags | Horror, Psychological Horror, Survival Horror |
Languages | English, Swedish |
Accessibility | Subtitles |
More posts
- Flashlight!Dec 12, 2019
- Devlog 1Nov 27, 2019
Comments
Log in with itch.io to leave a comment.
I actually forgot to attach the code
// Original code by Taylor
// https://biotechgames.itch.io/lost-footage
// In The Empty: Lost Footage
// DO NOT edit OR distribute
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerTransform;
public GameObject torchlight;
float xRotation = 0f;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
if(playerTransform.gameObject.GetComponent<PlayerMovement>().isEnabled == true)
{
float xRot = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float yRot = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= yRot;
xRotation = Mathf.Clamp(xRotation, -90, 90);
playerTransform.Rotate(Vector3.up * xRot);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
}
torchlight.transform.rotation = Quaternion.Lerp(torchlight.transform.rotation, transform.rotation, 1);
}
}
Well, that formatting worked 🤦♂️