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 Valenseth · Feb 26, 2014 at 07:25 AM · androidphysicspositiondragfinger

Android Moving with finger without breaking physics

I am making a game that involves a torrent of sphere objects coming towards that player, and you have to bounce them back by moving the player with your finger. I am using transform.position to achieve this, but due to .positions nature of breaking physics, the enemies are going through the players collider some times especially when it hits the corner or side and gets stuck inside the player. could someone suggest a fix that would stop objects from going through or getting stuck in the player collider? Either an alternate physics safe way to move the player with your finger, or some other way to stop the enemies from going through, thanks! here is what i am currently using if it helps any

 function OnMouseDrag()
 {
    point = Camera.main.ScreenToWorldPoint(
            Vector3(
              Input.mousePosition.x,
              (transform.position.y-Camera.main.transform.position.y),
              (transform.position.z-Camera.main.transform.position.z)));
  
    point.y = transform.position.y;             
    point.z = transform.position.z;
    farmer.transform.position = point;
 }
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 robertbu · Feb 26, 2014 at 07:26 AM 0
Share

I assume your player has a Rigidbody? If so, look at using Rigidbody.$$anonymous$$ovePosition() rather than directly moving through the transform. You might also look at using a joint to connect the finger position to the object like is done in the DragRigidbody.js script.

avatar image Valenseth · Feb 26, 2014 at 07:40 AM 0
Share

already tried using that, and for some reason didnt really make a difference, things were still going through the collider, bother the enemies are using a rigid body, but the player is kinematic, as for the joint thing, could you explain a little bit further please? I should also add that i locked the y and z position of the player

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

Finger gesture works/fails on different devices? 0 Answers

Ragdoll 2D character controller help 0 Answers

Adding a position offset to a force towards an object 1 Answer

How to make a sprite/gameobject follow your finger on Android? 2 Answers

Unity canvas keeps changing dimension and position 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