How to Fix Controller Input Snapping in Unity

preview_player
Показать описание
🎮 Let me know what other topics you want to learn about 🎮
👇 See below for time stamps 👇

Due to the way input axes are configured by default in Unity, when using the built in dead-zones, this causes the input to snap to the left, right, up, and down directions. This particularly becomes a problem when making games like twin-stick shooters where full free movement of the input axes are a must. Luckily the fix is pretty simple, hope this helps out!

0:00 - Introduction/Problem Demonstration
0:49 - Explanation of Dead Zones
2:11 - How Dead Zones Should Work
2:48 - How Dead Zones Work in Unity
4:17 - How to Fix the Issue
6:42 - Final Demonstration

Please 'Like' this video and share it with anyone who is interested in video game development.

Subscribe to the channel for much more independent video game developer related content including tutorials, design breakdowns, industry events, VLOGs, and much more fun stuff!

Links:
Blog:

My Game Development Studio's Website:

My GitHub:

My Setup:

As an Amazon Associate I earn from qualifying purchases.

#MadeWithUnity #UnityTutorials #UnityInput
Рекомендации по теме
Комментарии
Автор

This was SUPER helpful! I really do appreciate it. I thought it was just me that found that sort of bug for input. Thank you so much!

alejandrozamora
Автор

Worked like a charm, your explanation of how unity handles deadzones was incredibly helpful

chasefoxx
Автор

Just what I needed, thank you so much! I always wondered why this happened in Unity

sonicdoesfrontflips
Автор

Of all the videos, this helped me figure out my controller axis snapping issue as a poorly implemented hardware deadzoning issue, and I'm not even using it for Unity.

MrSonny
Автор

I am having an issue with movement when using an analog stick i am creating 8 diretionnal move and i want it to only be able to move in thoes 8 directions how do i solve this issue?. Here's the code if that helps?
{

public float moveSpeed;

Rigidbody2D body;

Vector2 moveDirection;

// Start is called before the first frame update
void Start()
{
body = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
moveDirection = new Vector2(Input.GetAxis("Horizontal"),

body.velocity = moveDirection * moveSpeed;
}
}

jaydos
Автор

I want to move my character only up-down-left-right without snapping
How can I do that?

Starıka
Автор

I have this same issue with the new InputSystem, any chance you know how to fix it there?

lordshoe
Автор

not the first time I see this kind of script... which does not help. I search for a smooth joystick movement, as smooth as the keyboard and this method does not work at all. Movement still snaps.

gloomywoods
Автор

Which controller do you use? Xbox One?
On Xbox 360 pad (not original) and on PS4 pad (original), snapping occurs even outside Unity (in controller properties window).

BTW. you forgot to add project files from this video:
📌 Download the project files from this video: 📌

GameDevMarek
Автор

This helped me solve a similar issue using the godot engine lmao thx

justintodd
join shbcf.ru