Пікірлер
@mactram7293
@mactram7293 8 ай бұрын
i used your code but something wrong with * -1, circle position and space ship move reverse, i remove it and it run right
@AbhijeetGoush
@AbhijeetGoush Жыл бұрын
how can you make it so that the joystick only appears when pressing in the bottom left side of the screen
@MythxuaBurgerKun_69420
@MythxuaBurgerKun_69420 Жыл бұрын
even im in mac
@LuisPaoloPaghubasan
@LuisPaoloPaghubasan 2 жыл бұрын
this was actually made by @PressStart
@_moonbeam4564
@_moonbeam4564 2 жыл бұрын
hello, I read all the comments below, poked around and found a great solution. (removed "* -1") and everything began to work as it should. Also thanks for such a good video. P.S not tested on phone yet. Edited Code: using UnityEngine; public class Joystick : MonoBehaviour { public Transform player; public float speed = 5.0f; private bool touchStart = false; private Vector2 pointA; private Vector2 pointB; public Transform circle; public Transform outerCircle; void Update() { if (Input.GetMouseButtonDown(0)) { pointA = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.transform.position.z)); circle.transform.position = pointA; outerCircle.transform.position = pointA; circle.GetComponent<SpriteRenderer>().enabled = true; outerCircle.GetComponent<SpriteRenderer>().enabled = true; } if (Input.GetMouseButton(0)) { touchStart = true; pointB = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.transform.position.z)); } else { touchStart = false; } } private void FixedUpdate() { if (touchStart) { Vector2 offset = pointB - pointA; Vector2 direction = Vector2.ClampMagnitude(offset, 1.0f); moveCharacter(direction); circle.transform.position = new Vector2(pointA.x + direction.x, pointA.y + direction.y); } else { circle.GetComponent<SpriteRenderer>().enabled = false; outerCircle.GetComponent<SpriteRenderer>().enabled = false; } } void moveCharacter(Vector2 direction) { player.Translate(direction * speed * Time.deltaTime); } }
@numerikachamba5976
@numerikachamba5976 2 жыл бұрын
That's awesome big man, keep the fire burning🔥🔥🔥🔥🔥
@darredYouTube
@darredYouTube 2 жыл бұрын
i got a problem. My middle circle got kinda stuck and doesnt follow my mouse. If you can help me i ll wait for your answer
@fluorescente
@fluorescente 2 жыл бұрын
I'm trying to find a script to fill the screen with objects, like the one you mention at the beginning, any ideas?
@fluorescente
@fluorescente 2 жыл бұрын
oh I wasted time in other tutorials and this one is the simplest and only working one! thanks!
@YayapipiStudio
@YayapipiStudio 2 жыл бұрын
simple and great !
@nbgamesllc
@nbgamesllc 2 жыл бұрын
I realize this is an old video but how would I update this to work with a canvas background instead of just a sprite?
@TheCoolestConcreteWall
@TheCoolestConcreteWall 2 жыл бұрын
why was there a text file in the circle and outer circle assets?
@berkefekeskin9172
@berkefekeskin9172 2 жыл бұрын
thanks for tutorial
@pedidosnica
@pedidosnica 2 жыл бұрын
Thanks, I was seeking this.
@markushoffmann3494
@markushoffmann3494 2 жыл бұрын
You just Gained a Sub, Like and Comment really good vid btw. awesome 🤩
@VrainbowStudioGame
@VrainbowStudioGame 2 жыл бұрын
can you explance abou PointA * -1 . whats is mean ? maybe i understand : 10 * -1 = -10 ????
@hddbvdcx
@hddbvdcx 2 жыл бұрын
Hey This is supercool! You helped me a lot.
@VoiD90009
@VoiD90009 2 жыл бұрын
Ui buttons work in editor but they do not work in android after building it
@hazemtv630
@hazemtv630 2 жыл бұрын
didnt work for me it said Object reference not set to an instance of an object and it and this are repeated maybe 60 times help
@Dacommenta
@Dacommenta 2 жыл бұрын
at 6:40 your voice temporarily went from Nerd to Jock 🤣😂 thanks for the video!
@amirhamzaozi2205
@amirhamzaozi2205 2 жыл бұрын
thanks very helpful
@emman6602
@emman6602 3 жыл бұрын
Great Tutorial! :D May I ask if how will I setup a boundaries for the cameras?
@maliktot7182
@maliktot7182 3 жыл бұрын
What i have to do to make my character move like to the bottomleft or bottomright?
@y0uyo
@y0uyo 3 жыл бұрын
thanks
@orhangunes3911
@orhangunes3911 3 жыл бұрын
this videao nice thanks so much man
@syympl257
@syympl257 3 жыл бұрын
I did everything as you said and did , but it didn't work neither with touch nor with the keyboard , i've spent my entire day watching videos and learning code so that i can move my object just left and right on mobile screen by touch , but still haven't found any success
@erkambilalbal7170
@erkambilalbal7170 3 жыл бұрын
THANK YOU A LOT! THIS ONE HELPED ME IN MY PERSONA PROJECT(IB) A LOT. THANK THANKS A LOT. YOU ARE A PERFECT PERSON.
@JungleGAS_
@JungleGAS_ 3 жыл бұрын
Nice video, Waldo please create a video about VR-games
@ElectronGOD
@ElectronGOD 3 жыл бұрын
Your tutorials are great! Plz keep continue making them.:)
@BBdaCosta
@BBdaCosta 3 жыл бұрын
Great video, very simple and clean. Liked the approach
@spartanh1438
@spartanh1438 3 жыл бұрын
best video on this topic ive found so far
@djalaljay
@djalaljay 3 жыл бұрын
You saved my Game thank you
@Frwager1998
@Frwager1998 3 жыл бұрын
Make sure you don't use Camera.main in the update function, it's very slow. Set it to a variable in start
@coleseph5321
@coleseph5321 3 жыл бұрын
I keep getting an index out of bounds error when running my script based on this tutorial, can anybody help?
@ВладиславДенис-б9ц
@ВладиславДенис-б9ц 3 жыл бұрын
God i love you.
@dcry1003
@dcry1003 3 жыл бұрын
just asking how do you do it so that you dont fall of a gameobject *im using this for a platformer but when i pull the handle downward my player falls through the ground gameobject*
@Sirandy12
@Sirandy12 3 жыл бұрын
For some reason the inner circle wont move that much, anyone knows why?
@bariunddieweltlernenmitspa899
@bariunddieweltlernenmitspa899 3 жыл бұрын
😄😄😄 Perfect Tutorial!
@Peburu01
@Peburu01 3 жыл бұрын
This method wont work with unity 3d and for those of you who are looking to mimic this same exact behaviour in unity 3d here is the code which does that. [Header("Movement Data")] public float MoveSpeed; private Touch Move; private Vector3 MoveStart; private Vector3 Direction; private void CameraPanAround() { if (Input.GetMouseButton(0)) { Move = Input.GetTouch(0); if (Move.phase == TouchPhase.Stationary) { MoveStart = Input.mousePosition; } Direction = MoveStart - Input.mousePosition; transform.position = new Vector3(transform.position.x + Direction.x * MoveSpeed * Time.deltaTime, transform.position.y, transform.position.z + Direction.y * MoveSpeed * Time.deltaTime); } }
@rebarius
@rebarius 3 жыл бұрын
Not working: I am getting: Index out of bounds for Input.GetTouch
@thuvienanime5441
@thuvienanime5441 3 жыл бұрын
start I zoom Camera with touchCount =2 , then I lift 1 hand. At this time the camera is not standing, it is moved by one hand I still touch. how can i fix it? thank you !
@strangerguy323
@strangerguy323 3 жыл бұрын
Thank you soooooo much <3
@rimia1650
@rimia1650 3 жыл бұрын
hi, many thanks for your tutorial. I used your code, everything is fine but Rotate var doesn't work. can you explain Rotate Boolean variable work?
@viliampaces5517
@viliampaces5517 3 жыл бұрын
Not working on mobile at ALL !!!
@Giburozu
@Giburozu 3 жыл бұрын
Not work in unity 3d :(
@itsthemeg
@itsthemeg 3 жыл бұрын
it doesnt work.....pathetic video
@coldbyte
@coldbyte 3 жыл бұрын
awesome tutorial thanks
@salvatornyam9991
@salvatornyam9991 3 жыл бұрын
Don't forget to tag Camera like Main camera. Not working. The outer ring not showing whyle touch(I can see it in scene and game untill push play). Inside circle appears on the other side of screen mirrored. I copy/paste the script, so no errors in it.
@greeng448
@greeng448 3 жыл бұрын
Amazing
@ArikCool
@ArikCool 3 жыл бұрын
Please Help! How can you make the character not glide? i want it to move while pressing and immediately stop while not moving
@ast4ay479
@ast4ay479 2 жыл бұрын
Increase the drag on the rigidbody i havnt used 2d but with 3d thats what i did in 3d
@ArikCool
@ArikCool 3 жыл бұрын
Here You Go, All Code You Need: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { public float moveSpeed = 300; public GameObject character; private Rigidbody2D characterBody; private float ScreenWidth; void Start () { ScreenWidth = Screen.width; characterBody = character.GetComponent<Rigidbody2D> (); } void Update () { int i = 0; while (i < Input.touchCount) { if (Input.GetTouch (i).position.x > ScreenWidth / 2) { RunCharacter (1.0f); } if (Input.GetTouch (i).position.x < ScreenWidth / 2) { RunCharacter (-1.0f); } ++i; } } private void RunCharacter(float horizontalInput) { characterBody.AddForce(new Vector2(horizontalInput * moveSpeed * Time.deltaTime, 0)); } }