- Home /
Character Animation won't work with FPS scripts
I have all the modelling and animations done and saved for my particular character for Unity, and I have got it to work just as a looping animated model. So I then tried to see if it worked as an actual enemy. So I took the FPS Robot AI scripts and tried to implement them with my model, didn't work. So next I decided to try to swap the models and animations in the Robot Prefab with the models and animations of mine, So I swapped the roothandle with my model(It's set up in a similar way but all the names of arms, legs, ect are different) and then I swapped the animations in the script with my new animations, carefully making sure they went in the right element(Again the name of the animations aren't the same but does that make a difference?). So I'm wondering what I'm doing wrong? How do I implement the FPS tutorial scripts with my model animation or vice versa correctly, I've been trying and retying this in different ways for a few days and still had no luck so I decided to ask here.
Answer by Matteaton83 · Nov 22, 2011 at 10:08 PM
Interesting, I'm approaching the problem from a different angle but I ran into a similar problem. I think the issue is that the robot animation scripts won't work outside of the FPS scene that they are originally in. Here was my process: I opened the FPS tutorial, made a new scene within the same project, put the robot prefab into the scene, set up two empty game objects with the autowaypoint script on them and then a plane for him to walk on. When you play the scene the robot is fixed in the starting position and moves back and forth between the waypoints but does not animate in any way. I wrote a debug structure into the AIAnimation script and it returns true for animation.IsPlaying("run").
So the broadstroke of this tgrech is that the animations won't play even if the robot has it's normal animations and I suspect that there is another script or option that is set in the original FPS scene that is solving this issue, but I can't offer a quick solution to what it is.
A possible workaround for you could be to work in the FPS's Level1 scene and replace the model and animations in there to test them. Good luck.
EDIT: I found my problem. Perhaps it's yours as well. The Time.timescale is set to 0 in the FPS Project Time settings. It gets set to 1 by a script called LockCursor. add this line to the Start method of your AIAnimation script
Time.timeScale = 1;
I had got the Robot to animate fine with its own animations, the problem was only encountered when using my own. I will try your solution soon though, and I will report back on whether it works. thanks for contributing either way.
It turns out this does seem to get it to start a run animation but nothing else, and no longer moves, though this may be a collision issue I need to sort out on a different matter
The Robot script looks for game objects with the FPS tutorial's autowaypoint script on them to deter$$anonymous$$e where to move to. If you don't have any it may just run on the spot.