FPS Controller with Unity's New Input System

preview_player
Показать описание
Learn how to make an FPS controller using Unity's new input system. We will cover horizontal movement, jumping, and custom gravity in this tutorial, and I will explain what everything does along the way.

----------------------------- Contents -----------------------------
0:00 Introduction
0:20 Installing the New Input System Package
2:22 Player Setup
4:30 Input Actions Setup
7:30 Getting Input from the Player
10:00 Horizontal Movement
13:20 Custom Gravity
16:25 Jump
18:55 Mouse Look
25:20 Cleaning Up the Scripts
Рекомендации по теме
Комментарии
Автор

For anyone having issue with the "isGrounded" check, this is what worked for me:

float halfHeight = controller.height * 0.5f;
var bottomPoint = - Vector3.up * halfHeight);
isGrounded = Physics.CheckSphere(bottomPoint, 0.1f, groundMask);

I found this on a Unity help forum.

Basically "transform.position" for the capsule collider appears to give you the bottom of the cylinder portion of the capsule object, when we want to draw the sphere at the bottom of the hemisphere part of our collider. The code above draws the sphere at the very bottom of the object meaning it will actually perform the grounded check.

No disrespect to the video creator as this may have just been me and many others making a stupid mistake leading to the method in the video not working, but since this is a common many people seem to be having I hope this can help some of you!

TheDropdeadZed
Автор

A fantastic adaptation of the Brackeys vid, but with the new input system. Definitely subbing! :)

tyb.c.
Автор

You know it is a good day when (SK) Practical Programming releases a new video

zombitek
Автор

I lost almost two days trying to make a good walk with this new system. i learnt how it works so, now i can improve it a little bit. i loved you video! Thank you for sharing!

FeiOTV
Автор

I was able to follow this tutorial pretty fast, but damn the values you set for sensitivity are crazy. I need my sensitivity X over 100 in order to look around normally. Guess that just depends on your system, and it works really great after finetuning the values, that's the power of the Unity editor after all. Thanks for the video!

tastypatrick
Автор

A tutorial that actually makes sense to me?!? Wow! This was the first tutorial that actually went into detail for first person movement with the new input system. I had watched other videos on the system, but none of them helped me with the movement until this video!

owenp
Автор

for anyone having trouble with the jump. Instead of checking "isGrounded" with physics try linking it with the character controller. isGrounded = controller.isGrounded;
this will make sure you are in ground on everything you step so you don't have to layer everything.

TheSiskyShow
Автор

Great Tutorial. Thank you, I am waiting for more.

o.
Автор

Thank you, your mouse clamp implementation was exactly what i needed. Godsent.

ekokataatheplacetobe
Автор

I need some help.... I did exactly the same thing as he did, but my gamepad right joystick sensitivity on X is slower than Y... I tried to put the same value on each of them, and it gives me the same result. The X sensitivity is slower than Y sensitivity....

nunomonteiro
Автор

this tutorial about the new input system is a lifesaver

xenstudio
Автор

I like it. so to the point without the extra talking around so you can focus and learn. very amazing job.

yudnai
Автор

If your having issues with jumping change the isGrounded = Physics.CheckSphere to Physics.CheckSphere(new Vector3(transform.position.x, transform.position.y - 1f, transform.position.z), 0.1f, groundMask); The issue stems from the pivot point being in the center of the player.

johnriendeau
Автор

the expression body you do to receive the input is no longer working.

elrymoe
Автор

My unity Version is 2020.3.22f1, in the Actions, New 2D Vector composite, was not showing, but it turns out its actually "add Up/Down/Left/Right Composite"

TheRealKaiProton
Автор

I'm struggling to understand the benefit of the changes to the input system (knowing nothing about it other than watching the brackey's video of the old system and then this one)...this actually seems more complicated than before, and also considerably less straightforward/transparent. I would've expected the new system to be more about being able to define all the movement parameters directly in Unity without still needing to have everything in code but I guess what do I know, I'm just a Unity noob.

Jaspovideos
Автор

I was having trouble with jumping until I moved the "verticalVelocity.y += gravity * Time.deltaTime;" & * Time.deltaTime);" lines to below the "if (jump) {...}" block. Otherwise controller.Move() is always called before verticalVelocity.y is updated within the "if (jump) {...}" block.

americanwieland
Автор

Big Thumbs UP!! I'm in a class for Unity atm and it just takes certain instructions for me to understand things! This was the absolute best on the new Input System for me!! Thanks for making this!!

MystiqMiu
Автор

everything works perfectly ! except you are not able to jump on slopes witch is very annoying have you solved this issue for yourself if so please share

lololollolololo
Автор

Hi!
It was a great video, however i have a little issue with the rotation. atleast one axis of the mouse delta always gives more, or less then 0, even when i let the mouse, and the cursor not moving at all. Tired to find the solution, but i'm hopeless now.

nagyFerko