- Home /
How to make my camera smooth?
I am making an FPS game, and I want the camera to be smooth, like this (with adjustable smoothness):
https://www.youtube.com/watch?v=z4dzbtUV-yM&feature=emb_logo
here's my code (you can use it to adjust it if you like:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SmoothMouseLook : MonoBehaviour
{
//Floats
public float sensitivity = 100f;
float xRotation = 0f;
//Vetors, Transforms, and GameObjects
public Transform playerBody;
void Start()
{
//Locks Cursor
Cursor.lockState = CursorLockMode.Locked;
}
void LateUpdate()
{
//Get's Input from da mouse
float mouseX = Input.GetAxis("Mouse X") * sensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
//Clamping
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
//Rotating
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
Answer by Llama_w_2Ls · Jan 08, 2021 at 09:32 PM
First of all, the overwatch effect was demonstrated in a TF2-map-like-style recreation of 2Fort. smh. Have you tried using Vector3.Lerp
? This smoothly interpolates between two positions, like a teleport position and current player position, which should create a smooth camera movement. @whatsisitstudios_unity
Your answer
Follow this Question
Related Questions
Steering Overcompesation 0 Answers
Edges not smooth on spheres / cylinders 1 Answer
Smooth swapping my game object 0 Answers
How can I animate an object? 1 Answer
How do I prevent camera shaking when focused on gameobject? 0 Answers