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 tenthplanet0 · Jan 10, 2013 at 11:41 AM · rotationcurve

how to shot a soccer ball in curve path according to the swipe type

How to move the soccer ball in curve path?? Please some one help me... I have to write a logic for swipe type.... If I will swipe vertically than the ball should travel straight to the goal. If I will swipe in curve shape for example, in "C" shape then it should travel in "C" path. If swipe in opposite "C" shape than it should travel in opposite "C" path. Please someone help me

Comment
Add comment · Show 9
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 tenthplanet0 · Jan 18, 2013 at 07:58 PM 0
Share

This is the link for the game. I think this game is only available for iPhone or Android,

http://pikpok.com/games/football/

Please help me in writing the logic

avatar image hgaur725 · Mar 06, 2014 at 10:17 AM 0
Share

hey did u implemented the curve Logic

avatar image hgaur725 · Mar 06, 2014 at 10:19 AM 0
Share

@tenthplanet0 plz do rply man.. m also doing kind of same thng

avatar image hgaur725 · Mar 10, 2014 at 10:43 AM 0
Share

plz can u tell me how to make soccer ball curve when flicked by user.. plz help me out

avatar image hgaur725 · Mar 10, 2014 at 10:44 AM 0
Share

@tenthplanet0 and thanx in advance

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by robertbu · Jan 18, 2013 at 08:39 PM

If you are using the Physics engine, you will need to add a small force at every frame to simulate the Magnus effect to make the ball curve. If you are simulating physics, then you can use something like a sine curve or a exponential curve to model the movement.

For detecting the "C" you would need capture all the points of movement in the stroke and evaluate them... something like find the max distance of any point from the line connecting the start and end points. The distance from the line could determine the amount of curve, the length of the line could set the initial velocity of the ball, and the which side of the line the max point is found would indicate which way the ball would curve.

Comment
Add comment · Show 15 · 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 tenthplanet0 · Jan 19, 2013 at 08:03 PM 0
Share

Thanks robertbu....I will check it out and if come across any problem then will definitely revert to you. Please be in contact to help me further... Thanks again

avatar image robertbu · Jan 19, 2013 at 08:18 PM 0
Share

I played a bit with getting a soccer ball to curve just to see how it looked. Here is a bit of test code:

 using UnityEngine;
 using System.Collections;
 
 public class Soccer : $$anonymous$$onoBehaviour {
     
     Rigidbody rb;
     bool b$$anonymous$$icked = false;
 
     void Start () {
     rb = GetComponent<Rigidbody>();
         transform.eulerAngles = new Vector3(0.0f, 15.0f, 0.0f); 
     }
     
     void Update () {
         if (b$$anonymous$$icked)   // Curve force added each frame
             rb.AddRelativeForce (Vector3.left*0.05f, Force$$anonymous$$ode.Impulse);
     }
 
     void On$$anonymous$$ouseUp(){
         rb.AddRelativeForce (Vector3.forward*2.0f+Vector3.up*1.0f, Force$$anonymous$$ode.Impulse);
         b$$anonymous$$icked = true;
     }
 }

Attach to a sphere with a Rigid body, set the size and mass values to something close to a soccer ball, and click on the sphere.

As for detecting the distance from a point to a line for the swipe, see this post:

http://answers.unity3d.com/questions/62644/distance-between-a-ray-and-a-point.html

avatar image hgaur725 · Mar 06, 2014 at 12:02 PM 0
Share

@robertbu applied this script its working Perfect But problem is the ball is making curve even if i flick the ball straight.. i want it to curve when user try to make curve gesture.. and plus the curve is making in one direction i.e to left..

avatar image robertbu · Mar 06, 2014 at 03:45 PM 1
Share

@hgaur725 - This answer demonstrates how to make something curve. It is not a complete solution with a curve gesture. Unity Answers is here to help you write your own code. I believe there are other, perhaps more complete answers to a curving ball. They don't include a curve gesture. There are still other answers that explore how to capture a curve gesture. It is up to you research them and then at least make an attempt to put your script together. If you get stuck, post a new question along with detailed specifics on what you are trying to do along with your code attempt. If you get stuck with part of the problem, post back with a single, specific technical question.

avatar image hgaur725 · Mar 10, 2014 at 10:42 AM 0
Share

@robertbu...Sir All i want when user Flick the ball.. and he try to make curve using his fingers then the ball should get curve.. i used the script u provided.. but the problem with that script is that when i flick the ball straight it takes the curve automatically .. plz sir help me out...

Show more comments
avatar image
0

Answer by Piflik · Jan 10, 2013 at 11:42 AM

Use rigidbodies and its methods (AddForce etc) and all of that will be handled by the physics engine.

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 benhumphreys · Mar 06, 2014 at 10:21 AM

Instead of trying to do something complex like gesture-recognition, instead record the position of the touch/mouse at each frame, and work out the distance and direction between it and the previous frame.

So each frame you will get a small change.

Use these to add forces to the ball and make it curve in the same direction.

Comment
Add comment · Show 2 · 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 hgaur725 · Mar 06, 2014 at 11:57 AM 0
Share

@benhumphreys can plz explain this via sum refernce script or smthng like that..in which a ball is flicked on touch.. and if we make gesture of curve it goes in curve.. thanx in advance..

avatar image hgaur725 · Mar 10, 2014 at 10:12 AM 0
Share

@robertbu...Sir All i want when user Flick the ball.. and he try to make curve using his fingers then the ball should get curve.. i used the script u provided.. but the problem with that script is that when i flick the ball straight it takes the curve automatically .. plz sir help me out...

avatar image
0

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

Check this asset its has both 2d and 3d implementation 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

13 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

Related Questions

How To Get The Position And Rotation For ALL The Children Of An Object For An Animation At Once 0 Answers

Evaluating Animation Curves in Full 0 Answers

How to move objects along a curve? 0 Answers

how to shot a soccer ball in curve path according to the swipe type 2 Answers

Animation rotation property with right angle curve 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