Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

I really liked the intro cut scene, and the first person controller was nice!

(1 edit) (+1)

Thanks, if you want to know how to make the camera sway then here it is. so, it's basically a weapon sway script but is on a game object that has the camera as its child object here is the script, 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class TILT : MonoBehaviour

{

    // by gigachad11

    [Header("Position")]

    public float amount = 0.02f;

    public float maxAmonut = 0.06f;

    public float smoothAmount = 6f;

    [Header("Rotation")]

    public float rotationAmount = 4f;

    public float maxRotationAmount = 5f;

    public float smoothRotation = 12f;

    [Space]

    public bool rotationX = true;

    public bool rotationY = true;

    public bool rotationZ = true;

    private Vector3 initialPosition;

    private Quaternion initialRotation;

    private float InputX;

    private float InputY;

    void Start()

    {

        initialPosition = transform.localPosition;

        initialRotation = transform.localRotation;

    }

    // Update is called once per frame

    void Update()

    {

        CalculateSway();

        MoveSway();

        TiltSway();

    }

    private void CalculateSway()

    {

        InputX = -Input.GetAxis("Mouse X");

        InputY = -Input.GetAxis("Mouse Y");

    }

    private void MoveSway()

    {

        float moveX = Mathf.Clamp(InputX * amount, -maxAmonut, maxAmonut);

        float moveY = Mathf.Clamp(InputY * amount, -maxAmonut, maxAmonut);

        Vector3 finalPosition = new Vector3(moveX, moveY, 0);

        transform.localPosition = Vector3.Lerp(transform.localPosition, finalPosition + initialPosition, Time.deltaTime * smoothAmount);

    }

    private void TiltSway()

    {

        float tiltY = Mathf.Clamp(InputX * rotationAmount, -maxRotationAmount, maxRotationAmount);

        float tiltX = Mathf.Clamp(InputY * rotationAmount, -maxRotationAmount, maxRotationAmount);

        Quaternion finalRotation = Quaternion.Euler(new Vector3(rotationX ? -tiltX : 0f, rotationY ? tiltY : 0f, rotationZ ? tiltY : 0f));

        transform.localRotation = Quaternion.Slerp(transform.localRotation, finalRotation * initialRotation, Time.deltaTime * smoothRotation);

    }

}