How can I make my ball moving on the touch screen? I want to make a round joystick.
I’ve used the following script:
function Update () {
if (Input.GetKey ("up")) {
rigidbody.AddForce (0, 0, 7);
}
if (Input.GetKey ("down")) {
rigidbody.AddForce (0, 0, -7);
}
if (Input.GetKey ("left")) {
rigidbody.AddForce (-7, 0, 0);
}
if (Input.GetKey ("right")) {
rigidbody.AddForce (7, 0, 0);
}
}
1 Answer
1
You need to look into the Input states for iOS, using touch is a bit different to mouse and keyboard :
Also look at reptilebeats Penelope link =]
Here is an example of reading different Touch States (scroll down to my answer) : http://forum.unity3d.com/threads/142758-Moving-objects-with-your-finger
An example on rotating with Touch Input : Rotate on drag for IOS? - Questions & Answers - Unity Discussions
And when the silly spammers leave UnifyCommunity alone, and it gets fixed, check this script. It’s what taught me about Touch Input : unifycommunity.com
i would look at the iOS example that unity has, penelope. it has a round joystick.
– reptilebeatsI don't understand c#))
– edredarfrom memory, the Penelope Tutorial is in unity's JavaScript =]
– AlucardJayi think their is a tool that can convert it to java, I'm not a 100% percent on that though. joysticks though i haven't done yet as i don't need one so i can't really help.
– reptilebeatsI just checked and confirmed that the Penelope Tutorial is in js, but you'll need Unity Remote to test it (which means a paid apple developer licence and provisioning). You may be able to go all the way through and run in a simulator (free apple dev licence), you'll just have to try it out and see.
– AlucardJay