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 sethuraj · Apr 27, 2015 at 07:36 AM · androidtouchgridswipe

Android Drag By Steps

Hey people,

I'm currently working on a grid based game and my blocks uses integer values to represent in the grid like vector2(0,1),vector2(2,3),vector2(8,5) etc.I'm incrimenting the position by a step value of one like the following

 //Function call will move the block  to right one column
 void MoveBlock_Right()
 {
     //Modify position to Right
     transform.position += new Vector3 (1, 0, 0);        
 
 }

Here I'm calling the MoveBlock_Right() function using the "Input.GetKeyUp (KeyCode.D)" which acts as a trigger to step the block by one grid point for PC platform.Now I need to convert this to android platform.But i'm a little stuck here with this I need to move the block by the step value using touch-drag and more acceleration I put to my swipe should move the block more steps.

Can any one point some light to this..?

Comment
Add comment · Show 2
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
avatar image BenouKat · Apr 27, 2015 at 08:06 AM 0
Share

I think you want to realize two different things.

You have 2 ways to do this :

  • Crossy Road style, by taping on a position on the screen, the character moves to one case in the direction of your finger. It's the easier solution cause all your need to code is just a piece of code which catch a touch (Input.touches), compare the position of the touch with the middle of the screen and decide which direction your character needs to move by calling the kind of code you just post.

  • Clash of clans style (to put buildings), you touch your character in the middle and drag him accross the world. And this is a complete different code, you need to touch, verify if it touch your character (with a raycast for exemple), then follow the touch position to move your character with it, etc etc...

$$anonymous$$ake your choice :)

avatar image sethuraj · Apr 27, 2015 at 08:18 AM 0
Share

@Benou$$anonymous$$at Yes I know this but how to convert the acceleration of the drag to the step increment..?Any suggestion with a sample piece of code to get start with ?

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

20 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

Related Questions

multi touch / swipe issues 5 Answers

Frame Drop on Touching or Swiping Screen 0 Answers

Camera swipe AND gameObject touch (Android) 1 Answer

any one now about the touch events of android swipe events on the android 1 Answer

Diagonal swipe issues on Android 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