- Home /
NPC entering and exiting a car with animations
Hello,
I would like to implement a system where an NPC can enter a car, be driven somewhere, and then exit it. I think I can code that, but what I'm having difficulty is handling the animations. Most of the posts I read through here have solutions where the NPC/player is instantly teleported into the vehicle, or they're made invisible. I want to be able to have the NPC being able to open the vehicle door, get in and sit, and then exit through the same door, and move the NPC position so that they're in the car. How would I do this through Mecanim?
One thing to note is that I am using Unity's NavMeshAgent; currently my NPC only has a walking animation (still need to add in an idle animation). What problems am I likely to encounter to get something like this to work?
Thanks!
Answer by StartStart · Oct 14, 2016 at 11:54 AM
If NPC move close to the cars ( OnTriggerEnter ) > lerp transform to a door ( Empty gameobject for only transform ) > play anim entering cars.
NPC play animation leaving cars > lerp transform to leaving position.
Your answer
Follow this Question
Related Questions
Issue with mecanim playing an animation using setbool 1 Answer
How to fluently transition into an animation state? 0 Answers
How to use mecanim to play specific animation clips when public static int condition is reached? 2 Answers
Serializing and restoring full Animation state 0 Answers
How to get the values of the animation? 0 Answers