- Home /
Scripting an animation for an NPC?
I've got my enemy AI script set up and it works great. When I get closer to my enemy, the enemy gets angry, chases and attacks me. The next step is to get the walking/running animation for my NPC. I understand how you would animate the player walking,have something like Input.GetButtonDown()and then have it triggered to whatever key you are using to walk forward. I'm a bit confused on how to have it on the NPC. maybe something like if the position changes? Thank you!
Answer by C10110 · Jul 20, 2014 at 07:32 PM
Ha, I found this on a search looking for the same answer. It seams a lot of people want a tutorial like this. I too have AI scripts that get things like capsules moving around just as I need and understand fine and well how to set up transitions for animations and script player controls, but am at a loss on how to set up npc scripts for animations.
People keep telling me "it's no different" and that all I have to do is substitute the code where the GetButtonDown code is used for my own event for the npc. But it just doesn't make sense to me. I have only been coding three months so an actual tutorial would be most helpful.
The example someone told me was like if the npc is seen by the player then make them do a certain animation. But that makes no sense to me as I don't want them only doing that animation when they are seen and...blah...
I feel like the way you're supposed to go about it is however your ai scripts are handled you go off that maybe? But again, I don't know how that code would be executed. So like, in my ai scripts I have guys that wander and find waypoints if they can. So do I need to tell my animation controller script to play certain animation when they are wandering? And then when they find a waypoint? I just don't get it man I'm right there with you, it is frustrating that nobody seams to think a tutorial on npc setup through Mecanim would be useful. As it so would be. There isn't even anything for this to buy in the asset store.