Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by behzad.robot · Jul 05, 2014 at 06:05 PM · androidmobiletouchdrag

Box Drag and throw away script for mobile?

Hi i everyone i was working on my game in which in one part the player has to Drag the boxes outta his/her way so i tried unity3d's default rigidbody dragger(Scripts Package)but it's spring like working is both good and bad but i guess it's about the best result i've got so far.The problem with this one is that once i release it goes flying up high ! Then i tried another code found here(http://answers.unity3d.com/questions/498396/how-to-click-and-drag-an-object-at-full-speed.html)but this one's too dependent to the player once i release the mouse it'll be freezed in it's place and wont keep on going which is bad for gameplay cos like this player wont be able to move lots of boxes one after another!I also tried http://youtu.be/QjUhQ4z6pF0 but it aint moving at all i did some minor changes in code but then it started moving like what was shown in the video and we were told that it was unity remote's problem(or sth like that :D)!Here's my edited version of that code:

 public var Target:GameObject;
 public var XLimit:float = 2.5;
 public var YLimit:float = 2.5;
 public var ScrollDistanceX:float;
 public var ScrollDistanceY:float;
 public var Hit:RaycastHit;
 public var layermask = (1 << 8) |(1 << 2);
 function Start () {
     ScrollDistanceX = transform.position.x;
     ScrollDistanceY = transform.position.y;
 }
 
 function Update () {
     if(Input.touchCount > 0 )
     {
         var TheTouch :Touch = Input.GetTouch(0);
         var MyRay  = camera.main.ScreenPointToRay(TheTouch.position);
         if(Physics.Raycast(MyRay,Hit,layermask))
         {
             
             if(Input.touchCount == 1)
             {
             //    Destroy(Target);
                 var ScrollDeltaX = TheTouch.deltaPosition.x;
                 var ScrollDeltaY = TheTouch.deltaPosition.y;
                 //ScrollDistanceX = Mathf.Clamp(ScrollDistanceX + ScrollDistanceX*Time.deltaTime*0.5,-XLimit,XLimit);
                 //ScrollDistanceY = Mathf.Clamp(ScrollDistanceY + ScrollDistanceY*Time.deltaTime*0.5,-YLimit,YLimit);
                 /*Target.transform.position.x = ScrollDistanceX;
                 Target.transform.position.y = ScrollDistanceY;
                 Target.transform.position.x=ScrollDeltaX*0.05;
                             Target.transform.position.y=ScrollDeltaY*0.05;
             }
         }
     }
 
 }

Anyone know how to fix this problem ?I mean u dragg a box in a path of ur own once u release it it'll keep on going a bit too!I'm looking for sth close to Corona SDK's Drag object example(Anyone who has worked with that program will probably know what i mean)or sth which is at least as smooth as bad piggies system but with the keep moving part ofcourse :(

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Dragging Camera based on Touch 0 Answers

Dragging UI Image by touch 3 Answers

Do UI Buttons work the same for Touch for an Android Game? 1 Answer

Why this simple code doesnt work? 0 Answers

How to touch, move and rotate 3D objects in XZ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges