this video is only one i found for joystick tutorial without any asset so far. very simple and clean video and easy to understand. thanks sir.
@richardhawkes8 жыл бұрын
This is exactly how tutorials should be. Short and concise. Not sure I understood that normalized bit, but I never did get the normalized thing anyway!
@justintucker34308 жыл бұрын
That helped a lot... I had to change the Script to work when I move the Anchors so that the image will "scale" to the screen and I wanted it in the Let side of the screen. Just make sure the Pivot on the background image is at x: .5 and y: .5 public void OnDrag(PointerEventData eventData) { Vector2 pos; if (RectTransformUtility.ScreenPointToLocalPointInRectangle(bgImg.rectTransform, eventData.position, eventData.pressEventCamera, out pos)) { pos.x = (pos.x / bgImg.rectTransform.rect.width); pos.y = (pos.y / bgImg.rectTransform.rect.height); InputVector = new Vector3(pos.x *2, 0, pos.y *2); InputVector = (InputVector.magnitude > 1.0f) ? InputVector.normalized : InputVector; JoistickImg.rectTransform.anchoredPosition = new Vector3(InputVector.x * (bgImg.rectTransform.rect.width / 3), InputVector.z * (bgImg.rectTransform.rect.height / 3)); } }
@AStarcraft2Noob8 жыл бұрын
Thanks for the tutorial. I was getting an error with setting the input vector correctly (pos.x*2 + 1 sets it past 1), so the joystick always goes to the far right. For those stuck, pos.x = (pos.x / backgroundImage.rectTransform.sizeDelta.x) basically gives the position of the touch as a percentage of the length. Same for pos.y but for height. So the fix is to find the offset from the center and multiply it by 2. New code: inputVector = new Vector3((pos.x - 0.5f) * 2, 0, (pos.y - 0.5f) * 2). This made the joystick respond correctly to the first touch. Hope it helps anyone confused. Edit: actually I think it has to do with me setting the anchor and position of the joystick as opposed to just the position.
@АлексейПодлубный-в6л7 жыл бұрын
Thank you man! I was in trouble but you help me )
@arkhainesyn90656 жыл бұрын
THANK YOU. SWEET JESUS. Think this has to do with the anchor being on the left side of the screen rather than the bottom lol
@putuokpi9646 жыл бұрын
ty man. lakad matatak!!!!
@letscreategame39545 жыл бұрын
thanks man
@manavgkrishna47664 жыл бұрын
Could u pls upload the ball motor and virtual joystick script in the comments...would be easier to refer.
@asianspaghetti28446 жыл бұрын
THANK YOU SO MUCH! Everyone else here on KZbin uses the same stupid asset package instead of making it from scratch, I'm so glad I found this!
@amberlewis0124 жыл бұрын
Well to be honest, that free pack is really quite useful. Learning how to make one from scratch though, is absolutely better!
@zzayy8 жыл бұрын
This was happening to me I'm not sure why but when it was inputVector = new Vector3 (pos.x * 2f + 1, 0f, pos.y * 2f - 1); it wasn't lining up with the mouse so i changed it to inputVector = new Vector3 (pos.x * 2f, 0f, pos.y * 2f); and it was fixed
@Owen3H7 жыл бұрын
thanks! :D
@zzayy7 жыл бұрын
Lynxyy yea dawg
@nestormejia60357 жыл бұрын
Thanks mate! I found the same problem
@BitliKutu7 жыл бұрын
inputVector = new Vector3(pos.x * 2f, pos.y * 2f, 0f); yorumum bulunsun bu şekilde düzeldi ;)
@LuishsTorres7 жыл бұрын
Ma dude! :)
@hufacoe9 жыл бұрын
You sir had just won a beer, a like and suscription! thank you so much I been looking for sth like this for ages
@ignacyn53464 жыл бұрын
I have one simple rule: if during watching tutorial video i solve my problem i give like, you got a like, thank you! ;)
@ironbullet41278 жыл бұрын
Can't Find Vertical and Horizontal ... Don't know why I just inserted it inside my MovementScript what you just did in the last part of the tutorial... And it can't find my VirtualJoystic Script
@mrcolorful45714 жыл бұрын
same. i need help
@kshitijjande44358 жыл бұрын
plz can you upload the project file on github?
@Amandin55274 жыл бұрын
4 years later...
@samivtg3 жыл бұрын
@@Amandin5527 26 likes
@Amandin55273 жыл бұрын
@@samivtg 🤣
@ismartt8 жыл бұрын
Thank you, this is just what I was looking for. I followed easily and managed to implement a joystick in my project. There is many useful stuff on your channel so I subscribed as well.
@tutocfproductions70657 жыл бұрын
Thanks for your tutorial but when I use the joystick, it goes to the right when I slide to the left.
@ThisIsDjYigytugd8 жыл бұрын
Anyone have the script for the ball movement? My code is exactly the same yet I'm getting an error for this. thisRigidbody.AddForce ((MoveVector * moveSpeed));
@diegopadilla48537 жыл бұрын
use instead getComponent().AddForce(MoveVector * moveSpeed);
@Fragaile6 жыл бұрын
WAYYYYYY better than any other joysticks cuz my ball now rotates with the motioN!! :DD
@dragony1177 жыл бұрын
Big Like And Subscribed I have been searching for this for so long
@virtualuniverse71303 жыл бұрын
Will the object climb a hill
@fury26138 жыл бұрын
Awesome man! Simply awesome stuff! Keep them coming!
@bastianmaburto8 жыл бұрын
Thank you very much... I was searching how to do that :D
@RizuHaque6 жыл бұрын
Please help.. I am having a player crontroller where the input of horizontal and verticals are keyboard buttons..how can i change them to the joystick inputs..???? Please please help
@enverucar95595 жыл бұрын
I have a problem problem is the name inputVector does not exist in the current context .what should I do pllease help me
@processor82677 жыл бұрын
You saved another developer's life man appreciated keep up :D
@n3ken7 жыл бұрын
woohoo :D
@Phexah8 жыл бұрын
Is there a way that I can make the joystick anchor to the current touched position? So the user does not have to be limited to the preset anchor point? Or is there a way to change the anchors to allow for this to work? What I am going for is being able to move the joystick anywhere on the left side of my screen and to shoot on the right.
@vigneshs28867 жыл бұрын
+N3K EN is there a shortcut in visual studio to generate all those override methods from the Interface we have mentioned?
@n3ken7 жыл бұрын
CTRL + .
@vigneshs28867 жыл бұрын
Awesome thanks :)
@deleteaman7 жыл бұрын
note if you are putting your controls on the bottom left. You will need to change the add or subtraction signs in inputVector = new Vector3(pos.x * 2 - 1, 0, pos.y * 2 - 1);//bottom left inputVector = new Vector3(pos.x * 2 + 1, 0, pos.y * 2 - 1);//bottom right Most controllers put the movement stick on the left.
@d3zar4 жыл бұрын
Thank you very much. I have a qustion to you. My camera also rotation by sliding screen touch drags. If i integrate this code is my camera and movement physics will blown .? or will works perfect .?. I tried this and it's buggy sometimes. How we can fix this .? Could you make a vide about this but with using this code .?
@peymanjeddi7 жыл бұрын
hi i have this problem does not implement interface member please help me
@barayeq7 жыл бұрын
hi why when i add idraghandler has say error does not implement interface?
@Dalinet6 жыл бұрын
This tutorial is Amazing, Thank You... Everything it's totaly clear... 🤟🏾
@appolmous74638 жыл бұрын
Wow thanks dude i needed this video so bad. Your the best!
@jawadahmadsheikh42707 жыл бұрын
can u send the code my controller isn't move
@HilSyirahRina8 жыл бұрын
hello, im creating a robot and i wanna control the arms using a virtual joystick and the arm is a child to the robot. the parent which is the robot has its own script for it to move around. do i have to make a separate script for the arms?
@Furismo8 жыл бұрын
i have problem when i have two VJ, when i end one touch two joystich go to Vector3.zero
@jeswer98 жыл бұрын
Hey N3K EN. You mention: "I''m sharing all I know about unity and game design for free " Does this mean that code from your tutorials can be used commercially in one of our own games?
@n3ken8 жыл бұрын
Yes, everything is free to use. If you would like to help me in return , please share the videos :P
@arunpandey48547 жыл бұрын
where is the tutorial for ball motor ??I have completed virtual joystick tutorial but joystick is not working because i cant find your ball motor mechanics?can u help me please?
@bambaskadunyalar6 жыл бұрын
I too...
@EasyKill4359 жыл бұрын
Hello, I followed your tutorial and it worked on the right hand side, but I want to put mine on the left hand side. For some reason, the control just goes all the way to the right whenever you use the joystick.
@ga1actic_muffin9 жыл бұрын
+Paolo Villanueva yep im getting the same issue
@ga1actic_muffin9 жыл бұрын
I fixed it. the way he coded it was not dynamic to have any other anchor point other than the bottom right corner. but i wrote this extra code to make that dynamic. with this code, you can set the anchor point to anything you want and it will still work (replace the line where you set the inputVector to the new Vector3 with this code): //use this to make anchoring dynamic. can anchor anywhere on your canvas and this code should account for it. float xFactor = ((backgroundImage.rectTransform.anchorMin.x - 0.5f)*2) -1; float yFactor = ((backgroundImage.rectTransform.anchorMin.y - 0.5f)*2); // the anchor becomes 0,0 on the canvas so this code sets the inputVector to the right position based on the 0,0 of the anchor inputVector = new Vector3(pos.x * 2 - xFactor, 0 , pos.y * 2 + yFactor);
@ga1actic_muffin8 жыл бұрын
+Casper LI click on the "show more" button and you will see it...
@ApexArtistX8 жыл бұрын
i add this in my game and the joystick jumps to the right side several pixels to the right.. until i lift the click.. then snaps back to the default.. whats wrong ?
@NROKenaCapOfficialPro7 жыл бұрын
I get this error Assets / VirtualJoystick.cs (20,23): error CS0621: `VirtualJoystick.OnDrag (PointerEventData) ': virtual or abstract members can not be private. Can you help me
@n3ken7 жыл бұрын
hello, redirect the question here: discordapp.com/invite/etX2zJB under #programming_help and I will answer you there! ;3 thanks
@asdjsahjdhasjdh7 жыл бұрын
when I used the script to a third person model it is just rotating like a ball, I want my character to move but not rotate?
@ThisIsDjYigytugd8 жыл бұрын
Just realized for the ball movement in Start it shows AddComponent when it should be GetComponent. That is why my ball wasn't moving.
@PCHardwareSoftware8 жыл бұрын
thanks that worked for me
@johanncepeda65076 жыл бұрын
How i can use your script on a cube? what i have to modify on script of movment? please
@jmprsh1537 жыл бұрын
hi i copied your tutorial exactly and when i try to tap/click on the joystick its like the the center is off... it jumps to an edge but then if i drag it around it becomes normal... i need the starting drag point to be exactly on the mouse position and drag with the mouse but it isnt working :/
@lonelyspeckarp6 жыл бұрын
Can I use it FOR FPS GAME MAKING? I WANT TO MOVE ONE CHARACTER LEDT RIGHT UP DOWN ANYWHERE...AND IN LAST POSITION WHY YOUR OBJECT GO SLOWLY?
@heshammohamed73117 жыл бұрын
the script does n't effect on the analog........
@micurobert68239 жыл бұрын
hey , u can say me how to modify the script to use the joystick to rotate my player?
@radicalgamettv4 жыл бұрын
any way to apply this to a 2d animated player object with all directions desired (movement wise anyways, think of UnderTale where the player only animates in 4 directions), thanks in advance, man.
@_paleman9 жыл бұрын
how to use your joystick and touchscreen ?, when I press the joystick, touchscreen pressed
@codingod7 жыл бұрын
In order to resolve the null reference pointer error within your player controller class add a public variable for the background image game object. Drag that gameobject into the variable within Unity itself. In the player controller add this line in start. joystick = bgImage.GetComponent(); (joystick being the Class instance)
@renzviana65916 жыл бұрын
But how the rolling animation apply on this sphere
@jiwoongkim89118 жыл бұрын
덕분에 많이 배워갑니다! 유니티 배우기 시작한지 이제 한달 조금 넘었는데 아직도 배울게 많다는 걸 느꼈습니다
@twinspower91915 жыл бұрын
What is this mean? NullReferenceException: Object reference not set to an instance of an object Movement.Move () (at Assets/Movement.cs:31) Movement.Update () (at Assets/Movement.cs:26)
@roebuck12318 жыл бұрын
this is not working for me, the joystick when i click on it goes -1 in y for me
@kinshuksinghbist75717 жыл бұрын
I can't write public VirtualJoystick in my movement script ...help me
@kilyumed7 жыл бұрын
In the end I get this error: Assets/MovFig.cs(31,20): error CS0428: Cannot convert method group `Horizontal' to non-delegate type `float'. Consider using parentheses to invoke the method how do i fix it?
@reynaldongjr6 жыл бұрын
Can you help meplease? I'm having null exception error from the poolnput() and joystick.horizontal(). i copied and tried your code but i still get an error
@krenarpiraj26288 жыл бұрын
+N3K EN when i write public float Horizontal() and public float Vertical() it shows me error CS0161 not all code paths return a value
@AllyG19677 жыл бұрын
Is this tutorial still the same on the newest version of unity?
@jayantbarthwal44707 жыл бұрын
In the ball script ,i am unable to add " Private virtualJoystick " component why?? plzzz help!!!
@doubledinogaming50488 жыл бұрын
I'm having a problem unity does not recognize VirtualJoystic am I missing something.
@Kai-Shin7 жыл бұрын
If I move Ball "Hierarchy" to "Project folder" for respawn, Joystick is missing and I can't drop in. What can I do?
@bilalsaeed46578 жыл бұрын
Thumbs Up man..... such a great stuff you covered.
@VishalKottarathil8 жыл бұрын
How to connect this to Horizontal and vertical input setting?
@glaucogoca8 жыл бұрын
My joystick ball doesn't follow the finger when is pressed. I touch the screen and the circle changes to the finger position, but when I move it the circle stay in the same position. What I'm doing wrong? Thanks a lot.
@glaucogoca8 жыл бұрын
I resolved my mistake. I was using: pointerEventData.pressPosition and I should use pointerEventData.position Works like a charm! :D
@mag_ist6 жыл бұрын
how to transform rotate implemetation, example for jetplane to rotate z axis while movement or car with y axis
@mag_ist6 жыл бұрын
i want to make the object rotating while movement
@TheBalalaikaVision8 жыл бұрын
If I chose this method of input and if I add a fire button on left side of the screen. Will the multitouch works with this method or not? Or I need to chose different method?
@ADI-xp4qe7 жыл бұрын
When You 1st tested this on pc was ur unity,s build settings with pc or Android??
@robertgazyan21747 жыл бұрын
Why did you mark these methods as virtual? Why you didn't implement OnDrag and other methods like a regular method, without virtual keyword ?
@AlessandroFragaGomes8 жыл бұрын
I have too many instances of Image, so I'm having hardd time finding the Image tha is supossed to be instancied..... I tried lots of things, but the script can't find bgImg..... what should I do?
@TheMarnoch215 жыл бұрын
Anyone know how I can make it so the camera moves? The game I'm developing is first person, any help appreciated
@FreDEV_OFFICIAL4 жыл бұрын
attach your cam to your gameobject as a child, if you need more help, ill see what i can do, have a nice day!
@amberlewis0124 жыл бұрын
Bit late but apart from doing what FreDEV said, you could also do what Brackeys did in his tutorial series and make it so the camera offsets from the player or something, so lets say your player is a sphere, the camera won't spin forever.
@nikolaipavlovi48 жыл бұрын
Благодарю тебя товарищ! Отличный урок.
@rodrigoalberto38188 жыл бұрын
Thank you so much for the code, this helped me alot. now i'm have a question, how a can rotate the GameObject in the same position the joystick ?
@batus68719 жыл бұрын
i can use this for mecanim and use it for my character?
@RST94135 жыл бұрын
ok. and how you set ur imput in setings ??
@Veyron1047 жыл бұрын
thare is no any actions when i click in that area. Debug.log don't write anything
@jamesmusta8 жыл бұрын
Hi! How I can relocate joystick position on touch(on any screen position)? If I move in Update() on touch began, OnPointerDown does not invoked and OnDrag does not invoked too. How I can do it? Thanks!
@abhinaysinghnegi41896 жыл бұрын
Why do we need to ratio of 0 and 1 pos.x = (pos.x / bgImg.rectTransform.sizeDelta.x);
@GrahamFMcElearney8 жыл бұрын
What does the word ped mean - is it a variable created by the system or by one of the functions somewhere? Sorry I'm very new to Unity G
@n3ken8 жыл бұрын
ped is the name of a variable i gave to the incoming parameter ( type of Pointer Event Data )
@noblesse70007 жыл бұрын
How do I create multi-touch when adding two or more joysticks? I want to move two or more joysticks at the same time. Also, how do I resolve EventSystem location conflicts?
@Entertainment-np3kp8 жыл бұрын
hey... please reply how did you learn unity3d
@llyyyyy34147 жыл бұрын
my player passes through the ground when i click play, can you help me with this?
@panendraommina34743 жыл бұрын
finally I made a Joystick .It works
@TreviQ9 жыл бұрын
awesome vid but i have a small issue. no errors but when i click on the joystick it just jumps to the left, even if i click on the center of the bgImg. the joystick jumps to a negative number as soon as i just click on the center of the joystick without dragging it to the left.
@maxreva12009 жыл бұрын
+TreviQ MusicXP had same problem. Solved it. I just removed the images and repeated all again - created it, made bottom right pivot (pressing shift, as on video), then created child image and attached sript to its parent - everything works fine. Try again. If not helps - try on a new scene and you'll see it on your own. the position of first image is just on the corner of canvas, by the way... Good luck!
@SantiagoEspanna7 жыл бұрын
If i wanted to make a character crouch with the joystick, what would it be the coding for it?, i have an input of crouch in vertical, now how do i call it? (btw, thanks a lot)
@x32gx9 жыл бұрын
Hey thank you so much for this excellent tutorial. I have one question if I may: It seems that if I drag the joystick using one finger the ball does move in the right direction exactly like in your clip. But if I touch with another finger on the device (while the first finger is still pressed), the movement immediately changes according to where I placed the other finger... How would you tackle this situation? Thank you!
@n3ken9 жыл бұрын
+Alon Minski You could add an additional condition to the joystick inputs, detecting which 'fingerId' is beign pressed right now. I recommend looking through this doc : docs.unity3d.com/Manual/MobileInput.html
@silverstone58237 жыл бұрын
is it ok when I use visual studio 2017 t make a C# script
@ramelo077 жыл бұрын
hey man, the joystick seems to work fine in my case, but my sprite also moves when i move my mouse around, without touching the joystick. any ideas on how to fix this ?
@JackWeller9 жыл бұрын
would this work for 2d platformer?
@brian138739 жыл бұрын
how can i rotate my space ship using horizontal and a raycast from the camera which make my rotate oon the y axis if you check out some top down space shooter game you know what i mean. i want to know how can i get that on the touch input and by using the cursor or crosshair, like have the vertical move the spaceship straight in a line and have the crosshair rotate the the spaceship by using the horizontal
@n3ken9 жыл бұрын
+Ikaros Uranus I would glady help you, but that will require more info on your game structure, think you could show me how you handle your spaceships movement?
@ТатьянаЧемерисова-о3ц9 жыл бұрын
+N3K EN The same problem. How to make a joystick for the game top view.
@n3ken9 жыл бұрын
+Татьяна Чемерисова The inputs you are getting are fine, now its just about how you'll be using these inputs
@brian138739 жыл бұрын
ahh
@brian138739 жыл бұрын
I think connect the crossahair with the camera.poistion and use the touch.input to control both
@markfaja2888 жыл бұрын
how about the jump?
@tayfun111006 жыл бұрын
if you face a problem with horizontal and vertical, update the that lines as "dir.x = joystick.InputDirection.x; dir.y = joystick.InputDirection.y;"
@martian20329 жыл бұрын
Good tut. only one thing, you should use Vector2 in all the places instead of Vector3.
@Orgems6 жыл бұрын
please what is the script of keyboard?
@tricoliciandrei78426 жыл бұрын
In Unity 2017.1f0f3, this code : inputVector = new Vector3(pos.x * 2 + 1, 0, pos.y * 2 - 1); is not necessary. And N3K how u get so good quality on your mobile ?
@firdausahmad17697 жыл бұрын
How to make a button for a car to brake? sorry, still new with unity
@husnainyousaf10329 жыл бұрын
You are awesome man!!. can u tell me how can i create moveable joystick. which appears on screen touches? like in hunger shark evolution?
@n3ken9 жыл бұрын
+David John Well you could simply turn on or off the Virtual Joystick UI on touch presses, i think that is how i would tackle the issue
@husnainyousaf10329 жыл бұрын
+N3K EN i used standard Assets for Joystick
@alextor50476 жыл бұрын
Do you memorize all those codes?
@ChethanBhandarkar8 жыл бұрын
hyy!nice tutorial please help i get an error in the begining, VirtualJoystick doesnot implement interface member 'Unity.Engine.Eventsystems.IDragHandler......... please help
@AmeThunderBolt8 жыл бұрын
what is the ballmotor.cs code?
@laynetrout81508 жыл бұрын
I don't know if you still check the comments on here, but how would I change the code to make the joystick on the left of the screen, rather than the right. Currently, if I just switch the joystick to the left and anchor it to the left at 0, 0, 0 and I press on the joystick, it clicks to the far right of the stick and I can't drive straight or to the left unless I push my mouse way off the screen.
@n3ken8 жыл бұрын
+layne trout Hey layne, i figured out that issue after releasing the video sadly, however we've got a better implementation in this one if you would check it out :p Its basically the same thing but we added i think 2 lines in the middle to handle the pivot point kzbin.info/www/bejne/bJyqqYaJa5t1l5o Cheers
@crappywizard8 жыл бұрын
is that joystick is capable of controlling a third person character?
@117giova6 жыл бұрын
Help Me in public VirtualJoystick joystick in BallMotor: { "message": "El nombre del tipo o del espacio de nombres 'VirtualJoystick' no se encontró (¿falta una directiva using o una referencia de ensamblado?) [Assembly-CSharp-firstpass, Assembly-CSharp-Editor-firstpass]", "startLineNumber": 14, "startColumn": 13, "endLineNumber": 14, "endColumn": 28 }