Search Unity

Animating a basketballer bouncing a ball - Best practice

Discussion in 'Animation' started by frankmat, Feb 1, 2016.

  1. frankmat

    frankmat

    Joined:
    Sep 14, 2013
    Posts:
    42
    Hi,

    I was wondering what people consider is the best practice for implementing a player bouncing a basketball.

    I have various basketball animations converted from 3dsmax such as dribbling etc which I am using mecanim. So the way I see it I have these 2 options.
    1. Include the ball animation as part of the animation within 3dsmax (I assume you can export both the player and the ball to Unity?)
    2. Include the animation of the player dribbling but use physics to bounce the ball.
    3. Include the animation of the player dribbling but don't use physics to bounce the ball. (Make the ball kinematic and move it that way)
    Currently I am looking at Option 3. I already have the ball and I can pick it up using IK and parent it to the right hand of the character. I was going to then in the dribbling motion "unparent" the ball and set the ball to be Kinematic. Then I would simple move the transform of the ball on it's Y axis by -0.05f per update... which makes the ball move towards the floor. Then once I detect a collision between the ball and the floor switch the Y axis transform of the ball to +0.05f per update so it starts bouncing up towards the right hand again... and so on and so on.... so it looks like the ball is bouncing between the hand and the floor.

    I did want to originally have the ball as part of the exported animation in 3dsmax but I thought by doing it this way it gives me more flexibility by using the standard running animations instead of the dribbling animations... and could even switch dribbles between hands etc

    Is this the best way of doing this? or is there a better way that I have not thought of?
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Just a warning, I barely qualify as an amateur animator.

    What if you animated the ball in 3DSMax, as a joint/socket/bone whatever it's called in the program, but don't include the actual ball when exporting. Then in unity, have the ball be a physics object, which can be parented to that bone when "caught" or whatever (deactivating physics, or going kinematic or whatever), and then will follow the imported animation. When thrown, the ball can be unparented and launched with physics.

    I can imagine how to do that with the Unreal Engine, so I assume there's equivalent functionality in Unity but please don't hurt me if I'm wrong.
     
  3. rh0bz

    rh0bz

    Joined:
    Jan 12, 2016
    Posts:
    21
    Have you done it? Can you show me your game ? I'm also having problem with dribble
     
  4. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Hey I'm sorry I don't have an example of this technique that I can show you.

    But here's a UnityAnswer post about how to parent to a specific joint/bone on the character:

    http://answers.unity3d.com/questions/51929/attach-object-to-bone-ingame.html

    You should be able to use that to make an object follow a predefined animated point on the character.