How to make a EASY First Person Controller in Unity, quick and easy!

Опубликовано: 17 Февраль 2026
на канале: PineappleDev
4,150
73

TELL ME IF YOU HAD ANY ISSUES IN THE COMMENTS!

CODE: (angled brackets are just spaces instead, youtube doesn't allow them 😥 )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
private float y, x;
private Rigidbody rb;

public bool grounded;

public float walkSpeed = 5f, sensitivity = 2f;

// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
rb = gameObject.GetComponent Rigidbody ();
}

// Update is called once per frame
void Update()
{
grounded = Physics.Raycast(rb.transform.position, Vector3.down, Camera.main.transform.localPosition.y + .5f);
if(Input.GetKey(KeyCode.Space) && grounded)
{
rb.velocity = new Vector3(rb.velocity.x, 5, rb.velocity.z);
}
Look();
}


void Look()
{
x -= Input.GetAxisRaw("Mouse Y") * sensitivity;
x = Mathf.Clamp(x, -90, 90);
y += Input.GetAxisRaw("Mouse X") * sensitivity;
Camera.main.transform.localRotation = Quaternion.Euler(x, y, 0);
}

void FixedUpdate()
{
Movement();
}

void Movement()
{
Vector2 axis = new Vector2(Input.GetAxis("Vertical"), Input.GetAxis("Horizontal")).normalized * walkSpeed;
Vector3 forward = new Vector3(-Camera.main.transform.right.z, 0, Camera.main.transform.right.x);
Vector3 moveDirection = (forward * axis.x + Camera.main.transform.right * axis.y + Vector3.up * rb.velocity.y);
rb.velocity = moveDirection;
}
}

Check out my games here! https://gamejolt.com/@Cringeyy/games
If you would like to support me you can donate to my cashapp $cring47 Anything Helps ❤❤

Twitch:   / cringeypineapple  
join the discord?   / discord  

HAVE A GOOD DAY :)


Making a game, game creation, creating a game, making a Roblox game #shorts #developer #gamedev #gaming #unity #games #newgame #workfromhome #videogames #gamedevelopment #indiegame #indiegamedev #indiegames #indiegame #karlson #dani #amongus #rust #raid #fullmetal #trending #new