I need a script was create a simply joystick in the screen was move the position and rotation of the 2d sprite in the scene
thanks very much
I need a script was create a simply joystick in the screen was move the position and rotation of the 2d sprite in the scene
thanks very much
You would need 2 pictures, one for the background (not necessarily a picture, just a game object) and a pad picture. Then you would attach a new script onto the background, and would use 3 interfaces - PointerUp, PointerDown and PointerDrag. PointerUp will trigger when you lift your finger from the screen - you want it to return the stick to the original position and your input Vector2 to Vector2.zero. OnPointerDown will do the same thing as OnDrag will do; you want to calculate the offset of the pad picture from the anchor (the center) of your background picture, also normalizing the vector so it cannot get out of bounds. When you calculate the difference, you can then convert that difference to some sort of input vector. You can use that input vector as a quantum of your character’s velocity.
If you’re simply looking for a script to do your job without actually understanding how to do it, there are plenty of tutorials on the internet that will give you that, although I wouldn’t recommend it.