Тёмный

Easy Joystick for Mobile with Input System in Unity 

samyam
Подписаться 77 тыс.
Просмотров 141 тыс.
50% 1

Today we will use the new input system in Unity to add an on-screen joystick to our game. This works on both desktop and mobile phone devices.
ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓
sam-yam.itch.io/samyam-full-s...
Using an on-screen stick will pipe the values to a different control type, aka Gamepad stick, where we can then use an input action asset to read it's value in our script.
►📥 Video Source Code 📥
/ 50464914
►🔗 Relevant Video Links 🔗
ᐅKenney Onscreen Controls
www.kenney.nl/assets/onscreen...
ᐅCharacter Controller Move Script
docs.unity3d.com/ScriptRefere...
Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won't cost you any money, they will help me fund my development projects while recommending great assets!
😎 Cool Unity Assets 😎
ᐅPeek - Editor Toolkit: assetstore.unity.com/packages...
ᐅEditor Console Pro: assetstore.unity.com/packages...
ᐅRainbow Folders 2: assetstore.unity.com/packages...
🤝 Support Me 🤝
Patreon: / samyg
Donate: ko-fi.com/samyam
►⏱️ Timestamps ⏱️
0:00 Intro
0:07 Setup
0:31 On-screen Stick
1:42 Control Path
2:21 Adding Another Joystick
2:50 Input Action Asset
4:19 Input Action Usage Example
5:13 Joystick Image
6:32 Build to Phone
6:48 Outro
💖💖THANK YOU TO ALL MY PATRONS 💖💖
❯❯❯ My Links ❮❮❮
💗 Patreon 💗
/ samyg
💬 Discord Server 💬
/ discord
🐦 Twitter 🐦
/ samyam_utube
📚 Facebook 📚
/ samyam.youtube
🎵 Music 🎵
Ambient Gold
streambeats.com
👍 Like and Subscribe! 👍
🖥️ Computer Setup 🖥️
*As an Amazon Associate I earn from qualifying purchases.
www.amazon.com/shop/samyam
#madewithunity #gamedev #unity

Хобби

Опубликовано:

 

14 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 316   
@ricniclas
@ricniclas Год назад
Thank you a lot for those tutorials! You really have been helping my to understand how the new input system works
@filippobiancone1998
@filippobiancone1998 Год назад
I have been looking for a simple solution for all of yesterday. I'm so happy I found your video
@keatonrozema5787
@keatonrozema5787 Год назад
After over a half hour, got it to work, thanks
@philipkaltsounis8097
@philipkaltsounis8097 3 года назад
awesome video! I'm trying to learn the new Input System and your videos certainly help
@espiritualidadedesvendada
@espiritualidadedesvendada 3 года назад
It's Really Helpful!!! thank you for making it easy and simple to understand!!
@samyam
@samyam 3 года назад
Awesome!
@ShinichiKudoQatnip
@ShinichiKudoQatnip 2 года назад
Where were you all my life? The best and easiest movement tutorial ever!!!!!!!!!!!!!!!!!
@smbiplob9476
@smbiplob9476 Год назад
Thank you a lot for those tutorials!
@mgames1984
@mgames1984 Год назад
Sensacional o video, extremamente organizado e direto ao ponto! Parabens!
@lucaslimagamedeveloper6787
@lucaslimagamedeveloper6787 Год назад
Eu também achei, consegui implementar facilmente. Porém eu só queria uma função, onde eu tocasse, o joystick acompanhasse... Mas assim já está de bom tamanho.
@sergiovega3115
@sergiovega3115 Год назад
Gracias, te amo ❤, nadie fue tan claro como tu.
@Maxchallenger458
@Maxchallenger458 Год назад
Thanks Sis Love your Work, it helped me a lot and saved my day. best of LUCK
@user-fv7vi1qo7r
@user-fv7vi1qo7r 6 месяцев назад
Simple and comprehensible. Thanks)
@myk3l9675
@myk3l9675 3 года назад
Awesome, thanks!
@Jullo96
@Jullo96 6 месяцев назад
Thanks a lot, lots of useful info and good practice tips here
@umairjamshaid2173
@umairjamshaid2173 Год назад
Thank you so much! You're a legend
@woodenfences
@woodenfences 3 года назад
Succinct. Useful. Inspiring. Thank you!
@samyam
@samyam 3 года назад
Thanks for the nice words! 😄
@iSnakeBuzz
@iSnakeBuzz 2 года назад
Hmmm I've subscribed because yesterday I've found a really good video on your channel and today looking for some information about this I found your channel again. So thank you again xDD
@samyam
@samyam 2 года назад
Woot woot! Thanks 😄
@chakibchemso
@chakibchemso 2 года назад
She can read yo mind buddy decades later i needed this too nice
@grandprime2014
@grandprime2014 Год назад
​@@samyam make video how to do it with 2d
@Ez-_-69.
@Ez-_-69. Год назад
​@@grandprime2014 it's same
@Ez-_-69.
@Ez-_-69. Год назад
​@@grandprime2014 use button for 2D though if it's top down joy stick is better and all the process is same
@user-hs5sd4fc7z
@user-hs5sd4fc7z 7 месяцев назад
Come on man... I works 3 weeks on this this and finally I finish that here 🥳❤❤❤❤❤ thanx alot
@eliorubenmc
@eliorubenmc 2 года назад
So easy, so nice! I love the voice of this woman! thanks!
@samyam
@samyam 2 года назад
Thanks!!
@DiYStylus
@DiYStylus 3 года назад
awesome, to the point
@freeformcreations
@freeformcreations Год назад
Well done!
@DanielAbonales
@DanielAbonales 3 года назад
This tutorial deserve thousands of subs thanks sam
@kozavr
@kozavr Год назад
great tutorial
@benbechia3582
@benbechia3582 3 года назад
Thanks why are you so extremely underated
@samyam
@samyam 3 года назад
Thank you! :)
@s4shrish
@s4shrish 3 года назад
Daaaamn, this channel is solid. Subbbbbed!
@samyam
@samyam 3 года назад
Thanks 😄
@Jimaniki
@Jimaniki 2 года назад
Thank you !
@ThePascalbriand
@ThePascalbriand Год назад
Really like your channel. Good job
@samyam
@samyam Год назад
Thanks!
@subzerocatalyst
@subzerocatalyst 2 года назад
first person with a twitter user pfp that is actually helpful and doesnt make people wanna die, cool.
@tetras699
@tetras699 Год назад
thank you Unity input system is good! i'm made high quality controller !
@Someone-ln8vk
@Someone-ln8vk 2 года назад
Great tutorial
@samyam
@samyam 2 года назад
Thanks!!
@gamedevelopmentwithunity2050
Very helpful I subscribed 💝💖
@samyam
@samyam Год назад
Thank you!
@antisony2008
@antisony2008 Год назад
omg so pro, I wish I were at your level
@samyam
@samyam Год назад
practice makes perfect :)
@carlabalos3884
@carlabalos3884 2 года назад
Thanks!
@Diertstarr
@Diertstarr 9 месяцев назад
Thanks for the tutorial - this Unity input is so convoluted. Godot FTW!
@acikgozemre
@acikgozemre 2 года назад
wow Thanks!
@SAL73VFX
@SAL73VFX 2 года назад
Is there a tutorial of yours where you explain step by step how to code the character script instead just to copy from the documentation? thanks for the tutorial. :D
@neilfosteronly
@neilfosteronly Год назад
Vector 2 to Vector 3 I was not sure how to do at first. Some may see that up on controller will use y for your rigid body. To have it use Z instead look at line 44 at 4:42 in the video. You need to have a new Vector 3 set to your (vector2.x, 0, vector2,y). Now your movement will work correct instead of up going up compared to the plane.
@seraph1007
@seraph1007 2 года назад
Hi, this video is great and helped out a lot. But I was wondering if there's a way to make the joystick more customizable. Before I switched to the new input actions I downloaded a free joystick asset pack and the controls on those feel better because of possibly lower dead zone and the fact that the center of the joystick can move according the finger's position.
@samyam
@samyam 2 года назад
Yeah you can change the On Screen Joystick script to fit your needs (or make your own joystick and follow their example). The new starter assets from unity also has a Virtual Joystick script with different functionality ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-CD0FlqllfIE.html
@Josue-Arreaga
@Josue-Arreaga 2 года назад
I am a bit confused, when did you set up your player/animations? is this a second part of a video? Could you direct me to the video if so.
@dcry1003
@dcry1003 2 года назад
question how can i change the right joystick to look around to just use the right side of the screen so i can put another button there for lke jump or slide etc. (also how can i make the movement have exceleration? so the more you move character the faster it gets)
3 года назад
Great video! Helped a lot. Thanks for it and keep going
@samyam
@samyam 3 года назад
Thanks!!
@nelsonjimenez9068
@nelsonjimenez9068 Год назад
Me gustó el video ❤
@samyam
@samyam Год назад
😄
@diegofelix9868
@diegofelix9868 2 года назад
Thanks for tutorial, please make walk and button running!
@a.technology1446
@a.technology1446 3 года назад
Thanks
@arcadehero1832
@arcadehero1832 2 года назад
Good one Sam ;)
@samyam
@samyam 2 года назад
Thanks!
@Apicurieux
@Apicurieux 2 года назад
A great tutorial again, clear and precise! Thank you so much. Now I have one question please, I implement both joysticks and it is working well. I have juste a trouble when turning the character around, the "Shoot" event is also triggered! Could you please tell me how to dissociate them? Or to make things easy for you, is that possible to add a shooting action button when user click inside the right joystick sprite? Thank you a bunch, regards
@samyam
@samyam 2 года назад
Hm, why would the shooting be triggered, unless it's on top of the joystick and it's being pressed. There's an OnScreenButton Component that will act similar to a normal button which you can use for your shoot button. I think that would be useful to you.
@diyvideos8836
@diyvideos8836 2 года назад
first of all thanks for the video. I have a question for you. Why does the joystick that I add in my Canvas not move in the editor or mobile device? where am i doing wrong?
@legendarywolf2372
@legendarywolf2372 2 года назад
this is amazing , but how to replace left stick with full screen touchpad ?
@dushes_botalov
@dushes_botalov 3 года назад
Nice ☺️
@Alex-On-VR
@Alex-On-VR 2 года назад
thx
@olexandrradchenko
@olexandrradchenko 3 года назад
Amazing! Very helpful!
@samyam
@samyam 3 года назад
Thanks!
@creepermods4641
@creepermods4641 11 месяцев назад
The anchor presets is not working properly. Oh i was just dumb, i didn't read the Alt+Shift.
@maxfun6797
@maxfun6797 Год назад
I have a problem when using this. Even when I'm not touching the joystick image, but when my click/touch is in the proximity, the joystick gets selected and moves. This interferes with other buttons that are near by.
@menesekinci
@menesekinci Год назад
Whenever I open a tutorial video. The trainers ask us to watch 250 videos they shot by saying "Yes, I showed this, I told you about it, you already know that". Just to watch and understand one video. This makes it even more complicated. I really don't understand why you are doing this.
@CadaverKuma
@CadaverKuma 3 месяца назад
Dawg its really not that hard
@haribodriving5951
@haribodriving5951 2 месяца назад
They make content. You are watching this for free to learn something. It's like 5 minutes long. This video doesn't show complete system cause it doesn't need to. Soooo go watch the other video that is also free and stop thinking the world is going to hand you everything in life.
@hrishikeshgarud7177
@hrishikeshgarud7177 3 года назад
Nice. But I have one question. Does using old way ( get inputs from update()) gives less frame rate ?
@samyam
@samyam 3 года назад
On the back end the input system has to run on every frame anyways to detect input so I wouldn’t think there would be much of a frame rate difference. You can run a quick profiler test using simple input to test it.
@MEGA_TREE
@MEGA_TREE 2 года назад
Nice
@NostalgiaNote
@NostalgiaNote 4 месяца назад
If someone runs into a problem like not working in the next scene, plz remember to put that EventSystem object under your UI_Canvans, which has a Singleton generic set up already.
@GG-rc8kx
@GG-rc8kx 3 года назад
awesome
@OpxGames
@OpxGames 7 месяцев назад
everything is on a video that i have no idea where.... thanks
@Jason-ph8pf
@Jason-ph8pf 3 года назад
Thanks! I love the content you are providing. FWIW I had one small problem. I noticed that the UI image wasn't moving around for me (see about 1:30 in the video). I fixed this problem by going into my EventSystem game object and changing from "Stand Alone Input Module" to the new InputSystemUIInputModule. If anyone else has a similar problem you may have a similar issue.
@samyam
@samyam 3 года назад
Thank you! :)
@blipblub2419
@blipblub2419 3 года назад
thanks
@brianmcalpine822
@brianmcalpine822 2 года назад
Hi Jason, I've changed to InputSystemUIInputModule in the event system but I still have this issue. The WASD controls move me but the joystick image doesn't move and therefore won't move on Android :( Any ideas?
@brianmcalpine822
@brianmcalpine822 2 года назад
Update: I had added the PlayerControls Input Actions asset to the event system, after reverting and using defaults it now works as this brilliant video shows
@stevevokhe
@stevevokhe 2 года назад
This man is the mvp right here
@hwanginYouppa
@hwanginYouppa 3 месяца назад
If I want to make it work on a mobile should I still keep it as gamepad left joystick?
@Joe-oq2zn
@Joe-oq2zn 2 года назад
Hi Sam, after implementing the UI and hit play, I can't drag the image around and move the joy stick. Any idea what's happening?
@mairinger80
@mairinger80 2 года назад
see earlier comment: I noticed that the UI image wasn't moving around for me (see about 1:30 in the video). I fixed this problem by going into my EventSystem game object and changing from "Stand Alone Input Module" to the new InputSystemUIInputModule. If anyone else has a similar problem you may have a similar issue.
@TheKr0ckeR
@TheKr0ckeR 2 года назад
Thanks a lot! how would i deal with if our camera is top right or smth.
@TheNbc27
@TheNbc27 2 года назад
I follow the video but I don't necassarily get the implementation into code. I am trying to use a joystick that essientially if held down (pass through i'm assuiming) triggers one function, if held up triggers another function... etc.
@TYNEPUNK
@TYNEPUNK 5 месяцев назад
Thanks, but for some reason it wont move for me. I ALWAYS have trouble setting up input on a new project :(
@mehmetakyuz5290
@mehmetakyuz5290 3 года назад
Great video! I have a question though. How can I enable input detection just tapping anywhere on the screen but not only Canvas left-pad that we did in the video?
@samyam
@samyam 3 года назад
Do you mean from anywhere in the screen move the joystick? You can make an invisible image covering the whole screen and attach the on screen joystick to it as a workaround, and then have a joystick image mimic the movement you are making on the invisible image for visual feedback. Is that what you mean?
@mehmetakyuz5290
@mehmetakyuz5290 3 года назад
@@samyam That's exactly what I meant. I made image with alpha 0 full-sized, and its working like a charm, thanks a bunch! I should have thought about that :D
@samyam
@samyam 3 года назад
Nice!! Yeah it’s a bit “hacky” but it works!
@TheKr0ckeR
@TheKr0ckeR 2 года назад
@@mehmetakyuz5290 Hello, can you give a little bit detail how to achieve that?
@_ciraz_
@_ciraz_ 3 года назад
Hey, do you have a video already on how to make the player switch between animations with the joystick? For example if the joystick is being moved max on any side, the character runs; if the joystick is being moved only a bit the character just walks; and if the joystick isn't being moved at all, the character idles?
@samyam
@samyam 3 года назад
No I don’t have an existing tutorial on that, you’d want blend trees. Nicky B has some good tutorials on animation and blend trees
@_ciraz_
@_ciraz_ 3 года назад
@@samyam Sadly I am a completely noob and his tutorials don't really explain it for mobile and how to use that in a script or maybe I am just blind and can't find it... Could you maybe do a tutorial on that which completes this video? It would mean the world to me and I bet for many others too🙏
@samyam
@samyam 3 года назад
I’ve put it on my potential future videos list but I have some videos planned before hand so I’m not exactly sure when the video will get made. Basically you want to use a blend tree to blend between two different animations using a value. Once you change that value and pass it into the animation component the blend tree will adjust the animation accordingly. Here is nicky’s video on blend trees for 3d games ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-_J8RPIaO2Lc.html
@_ciraz_
@_ciraz_ 3 года назад
@@samyam alright, thank you^^
@_ciraz_
@_ciraz_ 3 года назад
@@samyam I will wait for your video though because you can explain it better in my opinion 😅
@elshowdelwendigopixeliento4345
@elshowdelwendigopixeliento4345 2 года назад
Hi!, I'm using a game pad, and I have an issue. Maybe you can help :). My character has a blend-tree to manage the IDLE and move animations, and when I let the analog stick go back quickly to the center, the blend transition from run to IDLE go too fast. When I use keyboard this transition is OK. Any idea?.
@samyam
@samyam 2 года назад
Try printing out the values from the analog stick to see what values are getting registered (or use the input debugger ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ICh1ZEaVUjc.html)
@Usamerica12345
@Usamerica12345 Месяц назад
where do i get that on screen joystick script from edit: just realized you said it comes with the input system and i forgot to have the input system i thought you meant input manager
@kingoffuture2000
@kingoffuture2000 Год назад
i don't have any unity registry or input system in the package manager in Unity 2019.3.11f1 (64-bit) version
@a.u.3371
@a.u.3371 3 года назад
I made a game with wasd controls, and now i want to make a mobile version of it, though its gonna take forever to remake everything for mobile, so is their an easy way to change it in the same script maybe? Edit: I forgot to mention that I dont want joysticks, instead id like arrow buttons. is there a way for a button to receive the same input message as a keyboard arrow? like make the button on screen behave like the one on the keyboard?
@samyam
@samyam 3 года назад
The input system is designed to be easy to adapt for different consoles. What you can do is have 4 on screen buttons and each one overrides the control that you currently have bound, for example have one button override the up arrow key or W. It should “act” as those values and you shouldn’t need to change much in the code. Let me know if that helps!
@a.u.3371
@a.u.3371 3 года назад
@@samyam yeah thats what I want, but I cant find a way to make it real, u have a tutorial on ur channel that might help with UI and buttons n stuff?
@samyam
@samyam 3 года назад
Yeah I have some videos on using the UI with the new system, although I don’t have a dedicated video of on screen buttons Enable UI with the new system ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-TBcfhJoCVQo.html Controller and Keyboard Menu Navigation ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Hn804Wgr3KE.html Joystick ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-zd75Jq37R60.html ^ Concept should be similar as in the joystick video but use on screen button instead
@a.u.3371
@a.u.3371 3 года назад
@@samyam aight thx for ur time, ill check em all out.
@x.4132
@x.4132 2 года назад
I watched a few videos from you about movement and input. pretty good. but what about a video where you actually MOVE something? Couldn't find anyone.
@samyam
@samyam 2 года назад
Thanks! I have a playlist on character controllers here Unity Character Controllers ru-vid.com/group/PLKUARkaoYQT2XKPI7Aj9NVOxcI5OlnuK8
@ibarra309
@ibarra309 2 года назад
I did a right click and drag on the soft roll, now if I click Play the position clock starts but my ti cursor does not move and I cant
@CaliCG89
@CaliCG89 Год назад
Can you move the camera and the joystick at the same time?
@kingoffuture2000
@kingoffuture2000 Год назад
so ok i got it ,its available in newer versions
@KBforJesusChrist
@KBforJesusChrist Год назад
Can you make a video about mobile first person controller, I saw the one for pc but for mobile is not there
@maxxvr
@maxxvr Год назад
My player movement script dosent have anything, it’s just a normal script. how do I fix this?
@Echotrax
@Echotrax 2 года назад
So do i need to change the input handling setting to the new one or keep using the old one? It caused an error when i switched it to the new one.
@samyam
@samyam 2 года назад
You can also use both if you have packages using the old one, the error is usually because you are using the old input system while having the new one enabled. What kind of errors do you get? You can also ask on our Discord for help (link in description) :)
@khlad.t8028
@khlad.t8028 3 года назад
Can you make a Tutorial about changing image sprite based on Control Schemes?
@samyam
@samyam 3 года назад
By control schemes do you mean the current action map? You can do a check or every time you switch the map you can change the sprite. There is an Input System Sample package for Rebinding in the Package Manager, and in the sample the sprite of an image changes depending on the action associated it, so I recommend you check that out. I went over rebinding in this video but not the sprite portion ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-csqVa2Vimao.html
@LEARN-UNITY3D
@LEARN-UNITY3D Год назад
Hello pls help . No video is helping in my game no joystick works
@metrophoenixind
@metrophoenixind 3 года назад
Can you please make a video on saving and loading?
@samyam
@samyam 3 года назад
That’s a good idea! I’ll add it to my list for a potential future video.
@syedsadiq8631
@syedsadiq8631 3 года назад
Can you make tutorial about joysticks with out using input system for 3rd person movement
@samyam
@samyam 3 года назад
Hmm that’s not currently in my plans, I’m using the new system for most of my videos since that’s what unity will eventually one day switch to. But my videos shouldn’t be too hard to adapt to using the old system. Here is my third person video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ImuCx_XVaEQ.html
@BaconEggsRL
@BaconEggsRL 2 года назад
How do you read the playerInput values from the PlayerController script? What is playerInput an instance of? The component is called "Player Input" but I can't find anything like that when I try to reference it in code
@samyam
@samyam 2 года назад
You have to include the InputSystem namespace using UnityEngine.InputSystem; Then you can do: PlayerInput playerInput = GetComponent(); InputAction moveAction = playerInput.actions["Move"]; moveAction.ReadValue(); as an example
@BaconEggsRL
@BaconEggsRL 2 года назад
make sure your code is using UnityEngine.InputSystem;
@hehexd4787
@hehexd4787 2 года назад
Do you know how to make touchscreen camera control not with right stick? Because it feels so slow and slippery
@samyam
@samyam 2 года назад
You can try increasing the speed, also copying the OnScreen Stick script and adjusting it to your needs
@geroncrisjulius
@geroncrisjulius 3 года назад
I'm new to unity and was trying the to create an on-screen joystick using this tutorial. But I'm currently running to an issue where I cannot move the on-screen stick when testing on android. The stick can move when testing on windows. What should I check/setup in order to fix this? Edit: Tested the Input System samples (on screen controls and touch samples) but still experiencing the same issue. Using Input System v1.0.2 on Unity Editor 2020.3.11f1 Thanks
@samyam
@samyam 3 года назад
Try using Input System version 1.1.0-preview.3 (in the package manager, in the settings up at top, click advanced project settings and there will be an option to enable preview packages) forum.unity.com/threads/on-screen-joystick-sticking-on-android.1005158/
@geroncrisjulius
@geroncrisjulius 3 года назад
@@samyam will try this, thanks
@geroncrisjulius
@geroncrisjulius 3 года назад
After several testing, it seems that the problem is with the unity remote 5 and not with the input system as the controls work after building as an apk
@grzegorztarnowski3115
@grzegorztarnowski3115 10 месяцев назад
@@geroncrisjulius Confirmed - It worked on APK file
@wolfplaysgames8937
@wolfplaysgames8937 2 года назад
great video! is there a tutorial for how to make the camera just be controlled by swiping on the screen (like minecraft does it)? thanks so much edit: forgot to mention first person as well
@samyam
@samyam 2 года назад
Yeah! The video is a little older but I did a third person video of that ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-YV5KOZHsIz4.html (Basically as a hack you can make the joystick invisible and place it over the are you want the player to swipe then pipe that input to your camera look) I have a separate first person controller video (without joystick) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-5n_hmqHdijM.html And since then I found an easier way to replace the cinemachine old input system values (cinemachine input provider) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-we4CGmkPQ6Q.html
@samyam
@samyam 2 года назад
Ah I also have a swiping video that you can use instead of the joystick hack, and change it to your needs: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-XUx_QlJpd0M.html
@wolfplaysgames8937
@wolfplaysgames8937 2 года назад
@@samyam thank you for these however i am not having any luck. i wont go into why it doesnt work for me as its a somewhat long explaination, but to simplify it, it feels very unresponsive. rotating the camera based on the finger's position when the screen is first pressed compared to its current position would make it feel much better i think. however im not really sure how to go about doing that using the new input system, as i dont know how to get a constantly updating vector2 of the current position of the screen press
@samyam
@samyam 2 года назад
When you start pressing, you can start a coroutine that checks every frame for the position and updates the camera accordingly: // pseudo code (sry on phone kinda messy) Coroutine c; OnStartTouch() { c = StartCoroutine(UpdateTouch) } OnEndTouch() { StopCoroutine(c) } IENumerator UpdateTouch() { while (true) { // or instead you can check if the finger is pressed and not have to do a StopCoroutine call vec2 v = get finger position camera.transform.position or rotation = finger position yield return null; } }
@wolfplaysgames8937
@wolfplaysgames8937 2 года назад
@@samyam this worked great, but i do have a new problem. i can now only interact with my other buttons with right click. this might not be an issue as it could just be simulating a different finger, however i dont have the ability to export it to my phone right now to test. something that is definitely an issue is that when i interact with right click it still rotates the camera. how can i make the camera only rotate when being pressed off of the buttons? thank you for your help so far
@Daniel14Mejia
@Daniel14Mejia 3 года назад
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. If you ever get this error just go to project settings> Plater> other settings> active input handling> and change it to BOTH
@samyam
@samyam 3 года назад
Yeah that means you are using the old one somewhere, which I suggest not using both unless you have no choice (maybe a package you are using uses the old one). That may be the Event System using the old system, but it's hard to say without seeing the project.
@adudewithglasses9449
@adudewithglasses9449 11 месяцев назад
At 1:53 you choose Gamepad instead of Joystick even though this is a tutorial about adding a joystick control. Is there a reason why? After you clicked Gamepad you then clicked Left Stick. If you click Joystick it's basically the same except it just says Stick. Are the Left and Right Sticks in Gamepad different from the Stick in Joystick? Or are they the same? I'm probably just overthinking this so sorry if this is an unnecessary question. And thank you for this tutorial!
@Djkatchietsnouvastudio
@Djkatchietsnouvastudio 9 месяцев назад
Madzam you finished the video b4 linking the continuation of the video where you put the codezzzzz... assume its a totally new viewer accessing this video randomly
@turkaytandogan439
@turkaytandogan439 Год назад
float targetAngle = Mathf.Atan2(input.x, input.y) * Mathf.Rad2Deg + cameraTransform..... whats writing after miss ?
@xSPESHERx
@xSPESHERx 7 месяцев назад
Hello, thank you for this nice video, but i have a question. Houw to make this controller for 2D platformer games using virtual buttons? I can't to finde some tutorial about it, because many tuts are with joystick. If it possible to make some video, would be great. Or maybe just help me. Because on Unity Editor virtual buttons works good, but when i make Build for testing on Mobile, there are some bugs (player do not move or moving with lottle steps after many tap on buttons)... Maybe some bad Interactions setting... I don't know... I stuck with this 🤷🏻
@phantomBlurrrr
@phantomBlurrrr Год назад
Is there a way to "transfer" your "touch" from one button to another? I am trying to do as follows: There is "one" joystick on screen. But before it is running its joystick logic, you have to hold it for a second. The way it is setup is there is a regular "on screen button", behind this button is an image (circular slider), and behind the slider is the joystick. So what happens is you can tap the button and your tap will not be detected by the joystick (since the button is on top of it). This is fine, because the button can be the one that runs the slider (if you hold the button, the slider fills up over time, and if you release it, then the slider empties over time). If the slider becomes completely empty, it disappears. If the slider is FULL then the button AND the slider disappear. Now the joystick is available since the button and the slider, which were on top, have disappeared. Now the issue is that your touch input, which is what you used to tap and hold the button, isn't being detected by the joystick. You have to release your original touch and then touch again, this time the joystick is directly touchable since the button and slider are gone. So a solution would be for the joystick to detect touch if you DO NOT drag, so that the player can hold the joystick, which at the moment, IsPressed(), started, performed are NOT firing until you start dragging (so it doesn't look like it can be used to run the button's code, which is expecting the player to hold the button). Another solution would be to somehow transfer the original touch from the button to the joystick. That way when the button and slider disappear, the joystick takes over that touch input. Any clue how to do this? The idea is to have the player hold the joystick for like 2 seconds before the joystick becomes enabled. To give the player visual feedback, I added a circle slider which when full makes the joystick usable. So far, I have a button that runs the "touch and hold" logic (and slider). But once the "hold" action is complete, my joystick isn't detecting the input until the user released the original touch input and re-touches the joystick. It's setup as button in the front, slider behind it, joystick behind all that. That way, as the button and slider are enabled/disabled, the user can't tell (since they're using the same image asset).
@fmp6805
@fmp6805 2 года назад
Me: creating joystick from scratch samyam: ...so all you need to do is add On-Screen Stick component after all this time ...
@samyam
@samyam 2 года назад
😂
@phoenixdeath6055
@phoenixdeath6055 2 года назад
How do I undo everything because now all my code for player movements using the keyboard controls are not working.
@samyam
@samyam 2 года назад
That shouldn’t impact your keyboard input if you added another binding under your Movement action. But you can just delete the gameobject you made with the Stick
@Vozimeer
@Vozimeer 2 года назад
Is this joystick counts only parameters from - 1 to 1, or it reads like 0.5f or 0.6f (Please sorry for my English)
@samyam
@samyam 2 года назад
Counts from -1 to 1 and the numbers in between
@hexd6205
@hexd6205 2 года назад
why my Ui buttons not working when i press play
@Incomingson
@Incomingson Год назад
And what about the speed sensitivy?
@salvatornyam9991
@salvatornyam9991 3 года назад
When I create the Ui image it appears in centre and 50 times bigger than my 1920x1080 background in Scene window (I use 2d template).
@samyam
@samyam 3 года назад
Sorry I don’t understand your question; you can adjust the size of the image sprite with the scale in the Rect Transform component
@salvatornyam9991
@salvatornyam9991 3 года назад
@@samyam ui image is a part of ui canvas and they are much bigger than scene.
@samyam
@samyam 3 года назад
You can decrease the size of the canvas as well in the Rect Teansform There is also the canvas scalar for scaling to different monitor sizes correctly: docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-CanvasScaler.html
@Nick-rq4gy
@Nick-rq4gy Год назад
Dear Samyam, Can you help me make floating joystick on mobile with the Unity Starter Assets FPS controller, I cannot get it working, I have been on this a looooooong time can you help me?
@gameopedia01
@gameopedia01 2 года назад
Hi samyam, i got a problem with touch input. i followed your procedure and its working on some devices but not on all. it gives laggy output. Actually, its not working on my own phone but on other extra android devices that i have it is working fine. I want to know what could be the reason for this laggy output movement on using an on-screen stick. I have checked my phone's performance and touch inputs but nothing seems to be working. PLEASE HELP !!!!!!!!!!!!
@Schmiddi1004
@Schmiddi1004 2 года назад
this is because of unity remote 5... im banging my heads against the wall too. apparently using Input System version 1.1.0-preview.3 works for some cases... just change the version number in ur manifest.json file
@rafaelskiarteportfolio1098
@rafaelskiarteportfolio1098 2 года назад
I have the same issue! Did you find any solution?
@Dawiss2
@Dawiss2 Год назад
I had an issue with laggy joystick too, not sure if yours is same but I fixed it by moving my controls script at gameobject inspector above the rigidbody/collider. So probably the issue is because of priority of components, if physics components are first, the engine is doing physics calculations THEN doing what you have in your controls script, and it's the reason why it's laggy.
@94HellGate
@94HellGate 3 года назад
have they finally fixed it when using a player input component? last time i tried it made the player input auto switch to gamepad canceling all touch events
@samyam
@samyam 3 года назад
It cancelled events? What do you mean? If you subscribe to the events in your script the functions should be called if they have the other binding set.
@94HellGate
@94HellGate 3 года назад
@@samyam the PlayerInput component auto switches input mode (m&kb, gamepad, touch, ...) whenever you use them. and for whatever reason the onscreen joystick sending gamepad inputs makes it switch to gamepad mode stoping all touch input including the onscreen joystick touch input. so basically it used to cancel itself making it useless. it worked without the PlayerInput but then you have to do that part yourself
@94HellGate
@94HellGate 3 года назад
just asking if you happened to come across this as the PlayerInput component is quite useful otherwise
@samyam
@samyam 3 года назад
Hmm no I haven’t come across this that seems strange, maybe try piping it to a different vector2? possibly one that you can make custom? docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionBindings.html#writing-custom-composites Maybe also check the Input System Package settings (in Project Settings) and make a new settings asset with the list of supported devices. Let me know if that helps!
@ror123456789ify
@ror123456789ify 2 года назад
Hey @@94HellGate, did you find solution for this issue? I'm struggling with the same problem.
Далее
How to Get Smooth Movement in Unity's Input System
7:42
Unity's NEW input system in 13 minutes
13:02
Просмотров 14 тыс.
Ручка из шланга, лайфхак
00:11
Просмотров 15 тыс.
50 YouTubers Fight For $1,000,000
41:27
Просмотров 82 млн
Прятки #nyanmp3
00:25
Просмотров 140 тыс.
How to use TOUCH with the NEW Input System in Unity
24:11
choosing a game engine is easy, actually
15:08
Просмотров 333 тыс.
Unity's "NEW" Input System with C# Events
16:46
Просмотров 87 тыс.
Why these weird indie games BEAT the AAA industry
9:08
Can Paris fix its poop problem before the Olympics?
8:06
Times Square
0:16
Просмотров 7 млн
Всегда проверяйте зеркала
0:21