|
I've been mulling over this for a while now, and can't think of a solution. I have a top-down shooter prototype set up where the root object of the character has the CharacterMotor/Controller, and FPSWalker script on it. The character model itself (with the animations) is a child of this, with a LookAtMouse script on it (this is the only way I could figure out how to do the traditional top-down shooter/twin stick control setup, where you can look/shoot in one direction and move in another). The camera is simply in the scene, with a script that targets the player object, and looks at it from an offset above. My problem is, I have 4 animations: run, two 45 degree angle runs (running at an angle both left and right), and two side-run animations (left and right). I can't for the life of me figure out how I should determine which animations to play and when. I was going to try basing them off of normalizing the character controller velocity.x and z, but that would only work if it was the character controller was also the object with my LookAtMouse, and if I do that, the controls get all backwards when you're looking in the wrong direction. Obviously I can't just base them on the horizontal/vertical input axes, because you could, for example, be moving forward with the vertical input axis but looking in a different direction.
(comments are locked)
|
|
If I undestood what you need correctly then I would do something like this:
You could also blend between each pair depending on angle... Wow, that looks great... still trying to comprehend it though as i don't have unity in front of me right now. A few questions: I want to store the CharacterController velocity on from the parent object (the "move" object, not the "lookat" object) in that velocity var, right? Also, what if I want to have reverse versions of all those animations as well, for when hes moving backward (relative the lookat's transform forward)?
Jan 10 '11 at 01:41 PM
PrimeDerektive
After some tinkering I figured it out. Thanks!
Jan 11 '11 at 04:21 AM
PrimeDerektive
(comments are locked)
|
|
I think you should have one run animation, and that your rotate your player to fit the direction you want to run in. You would play your run animation whenever the movement stick was active, and you would calculate a heading that your character is moving towards. Finally, you would Slerp toward that angle with a "smoothing" variable. Example: I don't think that would work, because the character is always facing the mouse pointer (so you can aim your gun)... so in the event that you are moving and shooting, I can't be modifying his rotation both based on a movement heading and based on mouse position at the same time; and if I was shooting while moving sideways, a forward/backward run animation would look ridiculous.
Jan 10 '11 at 01:47 AM
PrimeDerektive
(comments are locked)
|
