detect Swipe NEW Input system ( touch / mouse ) | how to detect swipe in unity with New Input system

  Рет қаралды 12,277

Game Dev Geeks - game-dev, ᴛʜᴇ ɪɴᴅɪᴇ ᴡᴀʏ

Game Dev Geeks - game-dev, ᴛʜᴇ ɪɴᴅɪᴇ ᴡᴀʏ

Күн бұрын

Пікірлер: 23
@corn_enthusiast
@corn_enthusiast 18 күн бұрын
the main thing this video taught me is that i still have a lot to learn when it comes to coding 😆
@GameDevGeeks
@GameDevGeeks 18 күн бұрын
lol, if that's the main thing you learned then my video missed it's mark 🙃 don't worry you'll get it
@corn_enthusiast
@corn_enthusiast 17 күн бұрын
@@GameDevGeeks yeah it was mostly the syntax i struggled with since i'm still fairly new to programming, as well as this "new" input system. But i kind of followed the same logic you used in the video and got it working in the old input system, which i find much more intuitive. And because of this video i also learned what a coroutine is 😄
@jackoberto01
@jackoberto01 Жыл бұрын
I think It's important for consistency that swipeResistance is calculate based on length of the screen travelled rather than pixels. Resolutions users use can vary greatly and I believe the values you get back are pixel positions
@GameDevGeeks
@GameDevGeeks Жыл бұрын
thats an important point
@MichaelBrunner_nur_Michi
@MichaelBrunner_nur_Michi 9 ай бұрын
but don't do screen sizes vary more than pixel density? between phones and tablets, where a swipe with the thumb would still have a similar distance?
@jackoberto01
@jackoberto01 9 ай бұрын
@@MichaelBrunner_nur_Michi Screen sizes vary some but pixel density probably is more likely to vary by a huge margin. There's phones that have 720p resolutions and phones which are close to 4k in resolution that's about a 3 times increase in both width and height or 9 times increase in pixel density. While screen size may also double or triple that's unlikely if you're designing mainly for phones. An even more comprehensive solution may take the screen size into account if you want a real life "distance" as the parameter of when to trigger the detection.
@lyten4287
@lyten4287 10 ай бұрын
Thanks for such a great tutorial and for the link to the code.
@johnmichaeldeleon3298
@johnmichaeldeleon3298 3 ай бұрын
Hello, great video. Is it possible to return the Tap event ? For example to make the cube jump. Thank you
@SreeHarryy
@SreeHarryy Ай бұрын
thanks man!
@paulstaring6188
@paulstaring6188 8 ай бұрын
Question, I keep getting the error "NullReferenceException: Object reference not set to an instance of an object MovementManager.Awake () (at Assets/Scripts/CubeMovement.cs:13)" . Any clue how to fix that?
@GameDevGeeks
@GameDevGeeks 8 ай бұрын
Hi. you can add "[DefaultExecutionOrder(-100)]" on the line above "public class SwipeDetection : MonoBehaviour" in the swipe detection script. and make sure the InputAction move has a value in the cube script. if you follow the video carefully it 'should' be working.
@jhgfghjfuzrtfchchghgf
@jhgfghjfuzrtfchchghgf 11 ай бұрын
I dont understand a thing of whats going on here. what are the things you reference? what names did you use where? how do your inputactions look like?
@GameDevGeeks
@GameDevGeeks 11 ай бұрын
Hey! in 6:30 I made a static variable for easier reference to the swipe detection object. you can search for Singlton Patten to learn more about this. as for the names I'm not sure which names you are confused about. and the input actions are inside the script instead of an input action map and you can see their bindings at 7:30
@ErenBR562
@ErenBR562 Жыл бұрын
How can I pinch gesture mobile to zoom in and zoom out on the camera? I created a zoom in/out function using the mouse scroll wheel, however, I would like to know how I can pinch using the new system input, thanks!
@GameDevGeeks
@GameDevGeeks Жыл бұрын
kzbin.info/www/bejne/oHy5hX6Beddqd80 sorry for late response I had connectivity issues
@ErenBR562
@ErenBR562 Жыл бұрын
@@GameDevGeeks WoooW Thanks! Do you have discord? I wanted to show you how my script is, thanks!
@ErenBR562
@ErenBR562 Жыл бұрын
@@GameDevGeeksThank you my friend! I will be deleting the message because it contains your private contact, I already added you, thank you very much!
@i_am_reshad
@i_am_reshad Жыл бұрын
it helped me a lot man, just curious how to block diagonal swipes
@GameDevGeeks
@GameDevGeeks Жыл бұрын
one simple way would be to put else to only detect in one axis or the other like this: private void DetectSwipe () { Vector2 delta = currentPos - initialPos; Vector2 direction = Vector2.zero; if(Mathf.Abs(delta.x) > swipeResistance) { direction.x = Mathf.Clamp(delta.x, -1, 1); } else if(Mathf.Abs(delta.y) > swipeResistance) { direction.y = Mathf.Clamp(delta.y, -1, 1); } if(direction != Vector2.zero & swipePerformed != null) swipePerformed(direction); }
@GameDevGeeks
@GameDevGeeks Жыл бұрын
or you can do pretty much the same thing but check which direction is swiped longer: private void DetectSwipe () { Vector2 delta = currentPos - initialPos; Vector2 direction = Vector2.zero; if(delta.magnitude > swipeResistance){ if(Mathf.Abs(delta.x) > Mathf.Abs(delta.y)) { direction.x = Mathf.Clamp(delta.x, -1, 1); } else if(Mathf.Abs(delta.y) > (Mathf.Abs(delta.x)) { direction.y = Mathf.Clamp(delta.y, -1, 1); } } if(direction != Vector2.zero & swipePerformed != null) swipePerformed(direction); }
@GameDevGeeks
@GameDevGeeks Жыл бұрын
or you can do pretty much the same thing but check which direction is swiped longer: private void DetectSwipe () { Vector2 delta = currentPos - initialPos; Vector2 direction = Vector2.zero; if(delta.magnitude > swipeResistance){ if(Mathf.Abs(delta.x) > Mathf.Abs(delta.y)) { direction.x = Mathf.Clamp(delta.x, -1, 1); } else if(Mathf.Abs(delta.y) > (Mathf.Abs(delta.x)) { direction.y = Mathf.Clamp(delta.y, -1, 1); } } if(direction != Vector2.zero & swipePerformed != null) swipePerformed(direction); }
@maalainineelkharfi7493
@maalainineelkharfi7493 Жыл бұрын
thanks man, thats exactly what i needed
Rotate Objects with New Input System (Touch and Mouse)
11:31
Game Dev Geeks - game-dev, ᴛʜᴇ ɪɴᴅɪᴇ ᴡᴀʏ
Рет қаралды 12 М.
Drag and Drop with New Input system! ( Touch and Mouse )
11:41
Game Dev Geeks - game-dev, ᴛʜᴇ ɪɴᴅɪᴇ ᴡᴀʏ
Рет қаралды 11 М.
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН
Жездуха 42-серия
29:26
Million Show
Рет қаралды 2,6 МЛН
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
Use Unity's Input System Like a Pro
24:48
Paridot
Рет қаралды 32 М.
TOUCH CONTROLS in Unity!
16:09
Brackeys
Рет қаралды 1,3 МЛН
Unity tip: How to detect Swipe gestures in your game
4:27
XSGames 🌀 Frank Eno
Рет қаралды 946
Create Swipe left right movement in Unity for Mobile Games
3:06
Aaditya Malik Unity&Blender
Рет қаралды 130
How to use TOUCH with the NEW Input System in Unity
24:11
samyam
Рет қаралды 75 М.
How To Make UIs without frustration | Unity Beginner Tutorial
16:58
This is GameDev
Рет қаралды 37 М.
CONTROLLER INPUT in Unity!
16:44
Brackeys
Рет қаралды 375 М.
I Redesigned the ENTIRE YouTube UI from Scratch
19:10
Juxtopposed
Рет қаралды 792 М.
Война Семей - ВСЕ СЕРИИ, 1 сезон (серии 1-20)
7:40:31
Семейные Сериалы
Рет қаралды 1,6 МЛН