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.

What's the strategy to have an avatar sit in a chair that may have been moved?

Discussion in 'Animation' started by schuette, Oct 27, 2013.

  1. schuette

    schuette

    Joined:
    Jan 6, 2013
    Posts:
    14
    I'm fairly new. I can make a sit-animation in Blender with absolute coordinates, or one with a known offset relative to the avatar, and move those to Unity, but I can't figure out how I should make the avatar sit in a chair when I don't know the chair's position until run-time, as it may have been moved.

    Do I simply animate the avatar to sit, say, a meter in front of where it is now, and then add another transform to move that sitting avatar to the chair, or the reverse order, or somehow blend a known animation with a computed translation and rotation, or is there some better way to get the equivalent of a pose-ball in Second Life (i.e., sit over THERE) and ray-cast / click on the chair?

    Or do I invoke the "sit" animation, which I've created in blender to occur at (0,0,0), and also parent the avatar to a pose-ball (or empty object) which has an orientation and position and the chair as a parent, then LERP / translate the local coordinates and rotation of the chair over to 0,0,0 and zero-rotation (with respect to its parent) ?

    I just couldn't find an example of this, sorry.

    Thank you!
     
    Last edited: Oct 27, 2013
  2. schuette

    schuette

    Joined:
    Jan 6, 2013
    Posts:
    14
    Well, parenting to a game object (aka pose ball) then setting local rotation and position to zero works, and parenting the ball to a chairl lets the pose be adjustable so that works too.

    There are large number of post and tutorials on how to launch a "sit" animation, and how to make one, but they all seemed to assume it was obvious to everyone how to connect the sitting to a particular gameObject that was somewhere else, or a vehicle (as most of the car race games don't actually have the avatar sit in the car.)

    I'd still appreciate anyone who points out to me there's a better way to do this. Thank you!:D
     
    theANMATOR2b likes this.
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,228
    theANMATOR2b likes this.
  4. schuette

    schuette

    Joined:
    Jan 6, 2013
    Posts:
    14
    TonyLi, thank you, those are both eye-opening and very helpful links! What a great slide show!
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,228
    Glad to help! The folks at Naughty Dog are really generous for sharing so much of this kind of information. One of them, Jason Gregory, wrote a great book called Game Engine Architecture. (I have no relation to it other than thinking it's an excellent resource for game developers.)