Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

to swipe the ball on swipe direction as swipe speed in c#

Discussion in 'Scripting' started by Linus392, Dec 14, 2015.

  1. Linus392

    Linus392

    Joined:
    Aug 14, 2013
    Posts:
    24
    how to make the ball swipe on swipe direction in c# for bowling game.
     

    Attached Files:

  2. garrido86

    garrido86

    Joined:
    Dec 17, 2013
    Posts:
    234
    On the AssetStore you can find a library called "TouchScript" and it offers all you need.
    Good luck!
     
  3. CloudKid

    CloudKid

    Joined:
    Dec 13, 2015
    Posts:
    207
    What you have to do is save the Input.getTouch(0) position on phase.Began and phase.End, construct the direction verctor of those position ( http://stackoverflow.com/questions/5483937/direction-of-two-points ), then add force in that direction ( rigidbody.AddForce(direction * force)). Don't forget to normalize your direction (direction.Normalize()), and make sure that the y is 0, so the ball wont fly. I could write the code, but is better if you try yourself. Just post your code here, and we will see were you went wrong.
     
  4. Linus392

    Linus392

    Joined:
    Aug 14, 2013
    Posts:
    24
    thanks for idea...
     
  5. Linus392

    Linus392

    Joined:
    Aug 14, 2013
    Posts:
    24
    thanks for idea...
    [