x


Swipe in Unity3d

How to do swipe code in unity 3d java script? I am new to unity 3d. While swiping a specific object, the direction of object gets change.

more ▼

asked Nov 26, 2012 at 07:28 AM

sona.viswam gravatar image

sona.viswam
1.2k 123 136 157

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Check my answers here :

http://answers.unity3d.com/questions/318631/how-do-i-javascript-swipe-to-move-my-first-person.html

http://answers.unity3d.com/questions/289055/rotate-on-drag-for-ios.html

http://forum.unity3d.com/threads/142758-Moving-objects-with-your-finger


Here are some links I strongly suggest to all new users :

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/

Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/

this is the YouTube link for the above as one playlist : http://www.youtube.com/watch?v=-oXYHNSmTxg&list=PL27B696FB515608D2&feature=plcp

Character controller and terrain : http://cgcookie.com/unity/2011/12/05/introduction-to-character-controllers/

That is good to get started. Then start with a small tutorial, this is a simple 2D space shooter : http://www.unityjumpstart.com/ProofOfConcept_1/ : click on the videos part1.mp4 part2,3,4 =]

I just found another by our own Eric : http://wiki.unity3d.com/index.php?title=2DShooter : http://forum.unity3d.com/threads/7883-2D-shooter-tutorial

By then you should be getting the hang of things and starting to have ideas of your own. When you decide what kind of game you want to make, then look at each part you'll need. For example, if you want to make some terrain then walk around it with a character : http://cgcookie.com/unity/2011/12/05/introduction-to-character-controllers/

Here's another on the same 'site but I havn't checked the difficulty : http://cgcookie.com/unity/2012/02/24/game-planning-lunar-lander-01/

Basically then just search for tutorials, there are many out there, either written or on youtube.

the Unity Wiki tutorials : http://wiki.unity3d.com/index.php/Tutorials

A big list of tutorials : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html

Helpful page with information on using Built-In Arrays and Lists (you'll need this later!) : http://www.unifycommunity.com/wiki/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use?

The unity wiki link above is very handy with lots of scripts and shaders too (just check out all the links down the left, and the tabs along the top : http://wiki.unity3d.com/index.php/Scripts )

http://forum.unity3d.com/threads/132628-How-to-help-the-Absolute-Beginner

If you know what kind of game you want to make, edit your question and write there what you are thinking of, then there may be a tutorial out there for that!

But just be aware, you will do lots of typing, deleting, typing, bashing head on desk, being really happy when it works and you understand how and why. I hope this helps, Happy Coding =]

more ▼

answered Nov 27, 2012 at 06:23 AM

alucardj gravatar image

alucardj
29.7k 167 1055 221

@Jay kay. thanks..

Nov 27, 2012 at 06:40 AM sona.viswam
(comments are locked)
10|3000 characters needed characters left

You have to calculate yourself. See here.

more ▼

answered Nov 26, 2012 at 07:43 AM

DeveshPandey gravatar image

DeveshPandey
1.6k 18 21 32

code is also available to the given link, so can copy paste!

Nov 27, 2012 at 06:13 AM DeveshPandey
(comments are locked)
10|3000 characters needed characters left

This code i used for my game and its working successfully

   if(!pausechk){                
     if(Input.GetMouseButton(0)){    
         if(touchBool) { 
          touchBegin = Input.mousePosition;    
          primarygo=true;
          touchBool= false;
         }  
 }
 else
 { 
         if(primarygo){  
          touchEnd = Input.mousePosition;    
          primarygo=false;
          touchBool = true;
          giveAns=true;
          }         
 }
 } 
 
 if(giveAns){
 dist= Vector2.Distance(touchBegin,touchEnd);
     xdiff=touchBegin.x-touchEnd.x;
     ydiff=touchBegin.y-touchEnd.y;    
     if(Mathf.Abs(xdiff) > Mathf.Abs(ydiff)){                
         if(xdiff>5){
             pos="left";    
         }
         else if(xdiff < 5){
             pos="right";    
         }
         else if((Mathf.Abs(xdiff) < Mathf.Abs(ydiff))){
             if(ydiff > 5){
                 pos="bottom";
             }
             else if(ydiff < 5){
                 pos="top";
             }            
     }
 }
 giveAns=false;    
 }
more ▼

answered Mar 19, 2013 at 05:46 AM

sona.viswam gravatar image

sona.viswam
1.2k 123 136 157

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x7209
x467
x52

asked: Nov 26, 2012 at 07:28 AM

Seen: 7701 times

Last Updated: Mar 19, 2013 at 05:55 AM