Search Unity

Unity Physics - Throwing a curve ball

Discussion in 'Scripting' started by BSECaleb, Aug 31, 2009.

  1. BSECaleb

    BSECaleb

    Joined:
    Jan 29, 2009
    Posts:
    72
    Any suggestions on how to approach this? I know I could manually interpolate the balls transform along a curve but I would like the ball to interact with the physics system. How would I approach this using rigidbody scripting? I don't care if its faked or uses tricks as long as its predictable.

    -James
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You could just add a script to the ball that applies sideways/downward forces on each frame. In the FixedUpdate method, you would use something like
    Code (csharp):
    1. curveDirection = Vector3.down;  // ...or whatever
    2. rigidbody.AddForce(curveDirection);
     
  3. Jim Offerman

    Jim Offerman

    Joined:
    Jul 17, 2009
    Posts:
    177
    Use AddForceAtPosition() if you also want have effects like spin.
     
  4. games4ever

    games4ever

    Joined:
    Jan 23, 2014
    Posts:
    11
  5. Leaton

    Leaton

    Joined:
    Jun 21, 2013
    Posts:
    4