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 /
This post is currently awaiting moderation. If you believe this to be in error, contact a system administrator.
avatar image
0
Question by Justin0025 · Jul 29, 2013 at 05:00 PM · androidraycastinputmobiledrag

Character keeps snapping between two finger positions [Mobile, Android, Raycast]

Hello everyone,

I'm currently working on an Android title, and am having an issue with Input. I guess I'd still be considered a beginner with javascript, but I've got a good idea on how it works.

I currently have it so my left thumb controls the characters position by dragging, and my right thumb is in charge of shooting and power-ups. Now here's my issue:

We've got the character controllable, and the attack button working 100%.

alt text

When we are holding the attack button down, the player starts shooting properly. But...

alt text

When the player moves within range of the attack button, it snaps to its position, and cant move the character anymore unless we let go of the attack button, and are able to gain control back.


We've narrowed it down to this:

The characters hit box for the raycast detection is large. Reason for that is so when players are moving their thumb around quickly, they wont loose control of the character because of screen response delay. With that in mind, the character is snapping to the other thumb detection (the attack button thumb), because the raycast is detecting all finger inputs on screen, and when the other thumb is in range of the hit box, it snaps to it.

I've been trying to figure out how to solve this, and I think I have the solution in my head. I'm just having a hard time putting it into code...

I was wondering if its possible to only allow the raycast to detect one finger. So once the player gains control of the character, no other finger Inputs will interrupt the control.

I've attached the player control code below. Any help will be greatly appreciated.

 var player;
 player = GameObject.Find("PlayerFingerZone"); 
 
 private var ray : Ray;
 private var rayCastHit : RaycastHit;
 
 function Update () 
 {    
     for (var touch : Touch in Input.touches)
     {
         ray = Camera.main.ScreenPointToRay (touch.position);
     
         if(Physics.Raycast ( ray, rayCastHit))
         {
             transform.position.x = rayCastHit.point.x;
             transform.position.z = rayCastHit.point.z;
         }
     }    
 }



Thanks in advance.

d3.png (23.6 kB)
d2.png (24.1 kB)
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

15 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

Related Questions

Android input only works with remote 1 Answer

How to launch a Hyperlink on Touching a Game Object ? 0 Answers

Touch Input positions are different on iOS and Android? 2 Answers

Drag camera: Translate and DeltaPosition: move object a little further at end [ANDROID] 0 Answers

Box Drag and throw away script for mobile? 0 Answers


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