Hi,
I would like an NPC to sit down.
currently he walks to a sofa, is facing a bit the wrong way (another thing to fix) and I want to trigger an animation of him. sitting down using this.
Various questions arise.
1) How do I set up the controller? Do I place the sitting animation clip (75_16) into the controller, or does AC magically find it?
2) If I should place it in the animation controller, how is it wired? It has no parameter setting within AC, so I wouldn't need to make a ImSitting parameter and make transitions would I?
3) But if I could get it to trigger at all, wouldn't I need to have transitions BACK to the idle state?
4) But what if the rest of the scene is spent sitting down, doing a conversation with the user. Then I want to transition to what? A "sitting but Idle" animation?
So currently I have the above action, and in my controller I have this, which doesnt do anything...
I am asuming I will need to make some kind of "sitting pose" but for now if I can at least trigger the sit down, I can then worry about rotating him so he actually hits the sofa, and switching to a sat down
Thanks in advance
Mark
Comments
1) Any animation you want AC to play will need to be present in the NPC's Animator Controller.
2) It's up to you. The Character: Animate Action's Method field lets you choose between playing a clip by name directly (Play Custom), or by manipulating an Animator parameter defined in that character's Animator Controller (Change Parameter Value).
3/4) You'll need to transition back to the Idle state when you're ready for them to move around again, but again it's down to you when that is. If the "sitting" animation is non-looping, then it should just end on the last frame unless you have a transition that goes back to Idle. At the moment, you have a transition that relies on exit time only - which means it will always go back to Idle when it finishes playing.
If you want the character to sit until you till him to stand, I would recommend using a boolean "ImSitting" parameter as you suggested above to handle both the entry/exit states of the sitting animation - and only use the Character: Animate Action to manipulate that parameter's value.
The 0 on the Base layer fixed it. And thanks for elaborating on my choices. Ill implement your suggestion soon.
I notice another issue, and this may not be a thing that AC is involved in, and as such, maybe out of the scope of this forum, however as others may have attempted this, probably the same issue pops up.
So when my man sits, I align him by getting him to face a game object. But as you can see from the attached images, he hovers a little over the sofa. (the Sofa has no colliders) I thought it must be a capsule collider issue, but as you can see, if I play the animation from the animation window when NOT in game he sits correctly (or nearly).
Do you (or anyone) know why this is?
SOFA
PLAYED ANIM
In the animation asset's Inspector (selecting the model it comes from), try playing with the Y-position / baking into pose. Also, does he rely on Root Motion in his Animator component?
Try using an Object: Teleport Action to position him at the exact Marker you want him to sit from - does that get him to stay in the correct place? We can look into smoothing that transition afterwards, this is just a test.