i used your code but something wrong with * -1, circle position and space ship move reverse, i remove it and it run right
@AbhijeetGoush Жыл бұрын
how can you make it so that the joystick only appears when pressing in the bottom left side of the screen
@MythxuaBurgerKun_69420 Жыл бұрын
even im in mac
@LuisPaoloPaghubasan2 жыл бұрын
this was actually made by @PressStart
@_moonbeam45642 жыл бұрын
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); } }
@numerikachamba59762 жыл бұрын
That's awesome big man, keep the fire burning🔥🔥🔥🔥🔥
@darredYouTube2 жыл бұрын
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
@fluorescente2 жыл бұрын
I'm trying to find a script to fill the screen with objects, like the one you mention at the beginning, any ideas?
@fluorescente2 жыл бұрын
oh I wasted time in other tutorials and this one is the simplest and only working one! thanks!
@YayapipiStudio2 жыл бұрын
simple and great !
@nbgamesllc2 жыл бұрын
I realize this is an old video but how would I update this to work with a canvas background instead of just a sprite?
@TheCoolestConcreteWall2 жыл бұрын
why was there a text file in the circle and outer circle assets?
@berkefekeskin91722 жыл бұрын
thanks for tutorial
@pedidosnica2 жыл бұрын
Thanks, I was seeking this.
@markushoffmann34942 жыл бұрын
You just Gained a Sub, Like and Comment really good vid btw. awesome 🤩
@VrainbowStudioGame2 жыл бұрын
can you explance abou PointA * -1 . whats is mean ? maybe i understand : 10 * -1 = -10 ????
@hddbvdcx2 жыл бұрын
Hey This is supercool! You helped me a lot.
@VoiD900092 жыл бұрын
Ui buttons work in editor but they do not work in android after building it
@hazemtv6302 жыл бұрын
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
@Dacommenta2 жыл бұрын
at 6:40 your voice temporarily went from Nerd to Jock 🤣😂 thanks for the video!
@amirhamzaozi22052 жыл бұрын
thanks very helpful
@emman66023 жыл бұрын
Great Tutorial! :D May I ask if how will I setup a boundaries for the cameras?
@maliktot71823 жыл бұрын
What i have to do to make my character move like to the bottomleft or bottomright?
@y0uyo3 жыл бұрын
thanks
@orhangunes39113 жыл бұрын
this videao nice thanks so much man
@syympl2573 жыл бұрын
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
@erkambilalbal71703 жыл бұрын
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_3 жыл бұрын
Nice video, Waldo please create a video about VR-games
@ElectronGOD3 жыл бұрын
Your tutorials are great! Plz keep continue making them.:)
@BBdaCosta3 жыл бұрын
Great video, very simple and clean. Liked the approach
@spartanh14383 жыл бұрын
best video on this topic ive found so far
@djalaljay3 жыл бұрын
You saved my Game thank you
@Frwager19983 жыл бұрын
Make sure you don't use Camera.main in the update function, it's very slow. Set it to a variable in start
@coleseph53213 жыл бұрын
I keep getting an index out of bounds error when running my script based on this tutorial, can anybody help?
@ВладиславДенис-б9ц3 жыл бұрын
God i love you.
@dcry10033 жыл бұрын
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*
@Sirandy123 жыл бұрын
For some reason the inner circle wont move that much, anyone knows why?
@bariunddieweltlernenmitspa8993 жыл бұрын
😄😄😄 Perfect Tutorial!
@Peburu013 жыл бұрын
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); } }
@rebarius3 жыл бұрын
Not working: I am getting: Index out of bounds for Input.GetTouch
@thuvienanime54413 жыл бұрын
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 !
@strangerguy3233 жыл бұрын
Thank you soooooo much <3
@rimia16503 жыл бұрын
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?
@viliampaces55173 жыл бұрын
Not working on mobile at ALL !!!
@Giburozu3 жыл бұрын
Not work in unity 3d :(
@itsthemeg3 жыл бұрын
it doesnt work.....pathetic video
@coldbyte3 жыл бұрын
awesome tutorial thanks
@salvatornyam99913 жыл бұрын
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.
@greeng4483 жыл бұрын
Amazing
@ArikCool3 жыл бұрын
Please Help! How can you make the character not glide? i want it to move while pressing and immediately stop while not moving
@ast4ay4792 жыл бұрын
Increase the drag on the rigidbody i havnt used 2d but with 3d thats what i did in 3d
@ArikCool3 жыл бұрын
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)); } }