- Home /
How do I Javascript swipe to move my first person?
Hi, all. I'm creating a very simple information based app with Unity. My first person character is in a small area looking around. I know this would be really simple but I don't know where to find the information. I would like to NOT use joysticks but I want the user to "swipe" left to turn left and "swipe" right to turn right. I code in Javascript. Can someone please direct me to where I may find this information? I looked on old Answers postings but all I can find is scripting that just has the swipe info and not how to turn the first person character.
Thanks so much for any help you may offer. Tom
Dear @alucardj Thank you for your links. The forum one I had found earlier while looking and when I used the script in Unity, it came back as an error of being out of date. I will work with that one again and the others. I really appreciate your help.
The only problem is that you didn't post your links as an answer so I can't check it as being the answer to my question. I want you to get credit for it since it did answer my question. $$anonymous$$
I'm glad that helped. I thought you would find from these links how to detect a swipe movement, and from that create variables that could be used to move or rotate a character. I shall convert this to an answer for you, if you have any problems implementing your swipe into your character, ask in a new question and most likely someone shall help.
Answer by AlucardJay · Sep 17, 2012 at 08:37 AM
These links should help with how to detect a swipe movement, and from that create variables that could be used to move or rotate a character :
http://wiki.unity3d.com/index.php?title=Basic_iOs_Input_Tutorial
http://answers.unity3d.com/questions/188202/swipe-gesture-ios.html
http://forum.unity3d.com/threads/48601-Swipe-help-please
http://answers.unity3d.com/questions/292333/how-to-calculate-swipe-speed-on-ios.html
There is a basic answer I did on this question : http://answers.unity3d.com/questions/289055/rotate-on-drag-for-ios.html .
It basically uses the changes in touch.deltaPosition. $$anonymous$$uch more can be done than this i.e. for swiping and scrolling menu's, this is done by recording the last and current touchPosition, calculating the difference and stores for the difference between frames, touch.deltaPosition returns the same thing so for direct Inputs such as controlling a gameObject then touch.deltaPosition should be fine. Here's a link to an answer I wrote that records the changes in touch positions : http://forum.unity3d.com/threads/142758-$$anonymous$$oving-objects-with-your-finger
Just treat touch inputs like any other input e.g. Input.GetAxis returns a value between -1 and 1, so if you write your code imagining any input is between -1 and 1, it becomes easier to regulate the gameObject movements with : [input] speed Time.deltaTime;
Your answer
Follow this Question
Related Questions
Mobile FirstPersonSetup Controls Disappeared? 2 Answers
Help with jump 0 Answers
First Person Controller vs. Character (Penelope Tutorial) 2 Answers
How to calculate swipe speed on iOS 2 Answers