Hi, I am a 3D guy so programming can be a little overwhelming at times. So I have a character that I am trying to use in a sidescroller. I have my animations for run, walk, and jump imported into Unity. The way I understand Mecanim is that the animations need to move in the 3d software for them to actually move in Unity as opposed to doing in place animations (which I am currently using). I have been searching all over the place and haven’t found any good info on how to use in place animations with the benefits of the Mecanim states and blending and how to script this. If anyone has any resources or suggestions, it would be much appreciated before my wall gets a hole from beating my head against it. Thank!
As a developer, I must say that, if you are a 3d guy, you should find a developer. I don’t try to make 3d models since I’m a developer.
Don’t get me wrong. Learning new stuff(including programming) is good for a person. The problem is, if you are into programming, you can’t start it with complex stuff like game, animation, unity or mecanim scripting. You should begin with the very basics outside of Unity.
You can easily use Mecanim for in-place movement.
I assume you already have a movement script which lets your character move through the level.
What you need is to expand your movement script with the following (in JS):
//1. we need access to the animator component which is responsible for mecanim, so declare as a variable:
private var myAnimator : Animator;
//2. we need to let myAnimator know whom animator component we should use, so in Start():
function Start(){
//...
myAnimator = transform.GetComponent("Animator");
//...
}
//3. Now we can access the mecanim variables for example in Update() according how we move:
function Update() {
//move player with rigidbody.addforce or however you do
//now check in which state the player is and change the mecanim variable:
//for example if our rigidbody has velocity play walk animation:
if( rigidbody.velocity.sqrMagniture != 0 )
myAnimator.SetBool("isWalking", true);
else
myAnimator.SetBool("isWalking", false);
}
And don’t forget to properly set up the mecanim states: