Unity 2021 Adding Mobile Joystick Touch Controls

preview_player
Показать описание
In this video we will create a Mobile Joystick UI and connect it to a 2D platformer game so that it can be played on a mobile device :)

Assets used:

Learn to make a 2D platformer game and at the same time improve your knowledge about writing C# code:

Join the discord:

You can support me through Patreon:

00:00 Introduction
00:41 Kenney assets
00:59 Canvas / Scaling
02:13 Creating joystick UI
04:29 Joystick script
06:47 IDragHandler / Getting Events
08:54 anchoredPosition explanation
11:06 RectTransformUtility
14:24 Mapping to (-1,1) range
15:33 Moving the joystick
17:20 Calculating Movement Vector
17:41 MobilePlayerInput script
19:51 Adding a jump button
21:09 EventTrigger component
Рекомендации по теме
Комментарии
Автор

Great content! I used the same interfaces to build a D-Pad style input instead of the analog stick.
The official unity On-Screen Stick uses these interfaces too, but doesn't work with PlayerInput & MultiplayerEventSystem.
💯

SlowSeer
Автор

THX 4 Tutorial & answers. These helped me lot with building WebGL project compatybile with mobile web browser. With pleasure will watch your next videos.
I just to have work on limiting jump heights. Can't wait for tut with NEW Input system in 2022 version.

ukaszolszewski
Автор

Thank you very much. This is a very well put together tutorial. It would be appreciated in the future if you include a link to the code as text rather than it only being available in the video.

DrCord
Автор

It is a bit more difficult to read your code as u were using :, ?.
I rather choose to code without these by agreeing make the code line more to make it more readable.
But thanks anyway, i got the point.

-Engineering-
Автор

Hello, is it possible to make the joystick move to where the player puts their finger first?

tegomlee
Автор

when I add the panel there is a clear white line on the top right on my 2d game

GrowingEggplantion
Автор

How do I make the joystick actually move the player? doesn’t work

emilydavidson
Автор

Hey hi ? just watch your vlog do you know how to fix stuck joystick after changing scene ?

nathanguliban
Автор

How to move the player using this script. I try but he didn't work Right.

Dexter-rxxg
Автор

I copied everything you did but for some reason my character doesn't move at all. did I miss something? the joystick moves like it should and i have the player script on my player, but nothing happens when I try to move.

theisaackielofproject
Автор

top class this and it was spectacular thanks

Stinger-rqgy
Автор

Hi. I want to add a gamepad system to my mobile game, but it will be like this: When I press a key from the gamepad, the UIs on the screen will be setactive false, when I press the mobile screen again, the UIs on the screen will be setactive true, can you help?

filmlerleilgili
Автор

Can this be used with Unity 2019 Make an intermediate 3d survival game?

AmielShadow
Автор

How i get the IAgentInput can you gave me the code ?

Soupax_
Автор

Does unity still use cross platform input?

random_precision_software