Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 shweta-unity · Nov 23, 2016 at 10:53 AM · touchballtargetswipethrow

Throw a ball in target bucket with swipe but with one drop Unity3D

I am new to Unity3D.

I am working on a game in which i need to throw a ball to target bucket but that won't be a direct drop in a bucket, i need one drop in between and then 2nd drop will be in bucket ( like bowling ).

My camera is set as ball and target bucket will get distance in z axis. I tried different approaches but those will work in either to much of force or direct drop in bucket.

Code :

 private float factor = 50.0f;
 
 void OnMouseDown() 
 { 
     startTime = Time.time; 
     startPos = Input.mousePosition; 
     startPos.z = transform.position.z - Camera.main.transform.position.z; 
     startPos = Camera.main.ScreenToWorldPoint(startPos); 
 } 
 
 void OnMouseUp() 
 { 
     endPos = Input.mousePosition; 
     endPos.z = transform.position.z - Camera.main.transform.position.z; 
     endPos = Camera.main.ScreenToWorldPoint(endPos); 
     force = endPos - startPos; 
     force.z = force.magnitude; 
     force /= (Time.time - startTime); 
     GetComponent<Rigidbody>().AddForce(force * factor); 
 }
 

The problem with my code is, it adds too much force in z direction so the drop will be far away after the target bucket and force value for y direction is very low so it won't get in to target bucket.

So i need help to manage y and z axis force depending on swipe in a way so it look realistic.

Thanks for your help in advance.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fahadshafique · Sep 12, 2018 at 11:30 AM

Did you find any solution to the problem? if you find any then please tell me thanks,Did you find any way to solve this problem? please tell if you find out solution...thanks

Comment
Add comment · Share
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
0

Answer by Adishah11 · Sep 20, 2018 at 05:48 AM

Check this asset its has both 2d and 3d implementation with curve control link: https://assetstore.unity.com/packages/tools/physics/2d-and-3d-swipe-ball-control-96912?aid=1100l3bpb

Comment
Add comment · Share
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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Throw an object via touch/mouse flick 0 Answers

TouchPhase doesn't end when player swipes off screen 1 Answer

mouse input to touch input help please 0 Answers

Swipe menu, problem! 0 Answers

Deactivate Swipe Controls on Pause? 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