Character gets stuck in place when animations are enabled

I’m still a bit new to unity, so my apologies if this is a stupid question…

I have successfully imported my own character into Unity, and set up the animations and controls. My only problem is, as soon as I click the play button, my character drops through the terrain into the middle of nowhere, while the spring follow camera zooms out and starts shaking pretty bad. I looked into the “dropping into the middle of nowhere” issue, and found that if I parented my character to an empty game object then my character stayed on the terrain. However, it still gets stuck in place. The animations still work, but I can’t move anywhere. When I disable the animation script, everything runs perfectly, I just don’t have any animations. But the moment I re-enable the animation script, I get stuck again and the camera problems come back. Does anyone know how to fix all this? Maybe the animation script I’m using doesn’t work with the character movement script?

These are the 2 scripts. Once again, I’m still kinda new to this, so it could just be something obvious…

Character controls/movement:

var walkSpeed:float = 1.0;
var turnSpeed:float = 1.0;
var runSpeed:float = 1.0;

function Update()
{
    if(Input.GetButton("Forward"))
	{
	    transform.position += transform.forward * walkSpeed * Time.deltaTime;
	}
	if(Input.GetButton("Backward"))
	{
	    transform.position += -transform.forward * runSpeed * Time.deltaTime;
	}
	if(Input.GetButton("Left"))
	{
	    transform.eulerAngles.y += -turnSpeed * Time.deltaTime;
	}
	if(Input.GetButton("Right"))
	{
		transform.eulerAngles.y += turnSpeed * Time.deltaTime;
    }

}

Animations:

function Start ()

{

   // Set all animations to loop

   animation.wrapMode = WrapMode.Loop;

   // except these    
   animation["GetBalloon"].wrapMode = WrapMode.Once;

   animation["Throw"].wrapMode = WrapMode.Once;

   animation["Idle"].wrapMode = WrapMode.Once;

   

   // Put idle and walk into lower layers (The default layer is always 0)

   // This will do two things

   // - Since shoot and idle/walk are in different layers they will not affect

   //   each other's playback when calling CrossFade.

   // - Since shoot is in a higher layer, the animation will replace idle/walk

   //   animations when faded in.

   animation["GetBalloon"].layer = 1;

   animation["Throw"].layer = 3;

   animation["Run"].layer = 1;

   animation["Idle"].layer = 2;



   // Stop animations that are already playing

   //(In case user forgot to disable play automatically)

   animation.Stop();

}



function Update () {

   // Based on the key that is pressed,

   // play the run animation or the idle animation

   if (Mathf.Abs(Input.GetAxis("Forward")))

      animation.CrossFade("Run");

   else

      animation.CrossFade("Idle");



   // Throw balloon

   if (Input.GetMouseButtonDown(0))

      animation.CrossFade("GetBalloon");

      

   if (Input.GetMouseButtonUp (0))

      animation.CrossFade("Throw");

}

SETTINGS ON CHARACTER INSPECTOR:

Spring Follow Camera (Script):

Target = Sphere (Transform) (This is an invisible empty game object that I have parented to my character, just so I can adjust the camera position behind it.)

Distance = 4

Height = 1

Smooth Lag = 84.88175

Max Speed = 10

Snap Lag = 0.3

Clamp Head Position Screen Space = 100.5553

Line of Sight Mask = Nothing

Move Around (Script):

Walk Speed = 14.73448

Turn Speed = 133.6174

Run Speed = 0 (I don’t use this, as the character can only run, not walk, so I use the Walk Speed for that.)

Capsule Collider:

Is Trigger = No

Material = None (Physic Material)

Center = (X = 0) (Y = -0.1987256) (Z = 0)

Radius = 0.3199999

Height = 1.907082

Direction = Y-Axis

Rigidbody:

Mass = 1

Drag = 0

Angular Drag = 0

Use Gravity = Yes

Is Kinematic = No

Interpolate = None

Collision Detection = Discrete

Constraints:

Freeze Position = (X = Yes) (Y = No) (Z = Yes) (This is to prevent my character from sliding down hills even when not running, and even when they’re all unchecked, my immobility problem persists.)

Freeze Rotation = (X = Yes) (Y = Yes) (Z = Yes) (This is to prevent my character from bouncing all over the place, and even when they’re all checked, I can still move around, as long as my animations are disabled.)

Player Animations (Script) (No Settings)

Run Faster (Script) (No Settings)

Throw Faster (Script) (No Settings)

(The last 2 scripts are simply there to increase the speed at which the “Run” and “Throw” animations play.)

Finally! After the sleepless nights of frustration, I have found a workaround. (At least in my case.) If you parent your character to an empty game object, apply your controller script to that INSTEAD of the actual character, your character should then be able to animate AND move. It’s so crazy, even funny, that the solution was something this simple. Sometimes the only real problem is the fact that you think it’s a complicated script or animation problem and you’re thinking too hard about it, when it’s really just something as simple as this. Also, take into account what Owen said about putting a rigidbody on the PARENT and putting colliders on the CHILDREN. In my case, I put a rigidbody on the empty game object and a collider on the actual character, then locked the appropriate axes just so there’s no unnecessary sliding and rotating. I hope this will help anybody else out there who might get stuck at the bottom of the same hump I did, and feels like all hope is lost. I did, and was actually about to give up, but I pressed on, and succeeded. I also learned a thing or two about unity in the process. Thanks to everyone who tried to help also, especially Owen.

Usually the setup looks something like:

Empty with script for move+animate, collider (rigidbody?)  <-- Camera targets this
  Animated bones
    more subBones, etc...

So, the animations don’t “really” move you, as far as the camera and physics.

The camera is probably jerking all around because it either targets the moving child, or the animation is moving the parent. If the target moves enough, a crazed-looking camera is normal. Can try going to Scene view, when you Play. That will give you a better look at who’s moving how much.

Also, setting transform.eulerAngles.y isn’t recommended – can give some odd flipping, esp. if you add leaning, on Z.

Looks like you’re mixing two ways of moving. Picking the way you need and setting it up can be tricky.

Changing transform.position is like dragging in the editor. t has no respect for other objects. It’s really only good for moving things that are “outside” of the game – like a big selection arrow.

A characterController is a custom type for moving like a standard game character (for example, stopping on a steep slope and not sliding.) One drawback is it won’t push things – it assumes you’ll separately program what happens when you hit something.

A rigidbody with a collider wants to move by either setting velocity or using AddForce. Good for a steerable marble. A lot of work to make it good for a player. Some rigidbody comments: constraints apply to the automatic part. Locking Y stops gravity. You can always spin an RB, locked Y or not. Not locking Y-rotation says that if something bumps it, it can start to spin on it’s own.

The top parent should have the rigidBody. If not, the kids will move around while the parent stays. If you have a collider and your child has an RB, the child should fall through the ground. An RB with child colliders works fine.

I imagine your frustration, I was too… I resolve with EmptyGameObject with CharacterController and ThirdPersonScripts attached. Inside, my CharacterPlayer have the AnimationComponent. Thank You, your answer help me great!

My actual problem is: How I access my Character AnimationComponent (to play Idle, walk, running) with my Script attached in EmptyGameObject???

Hails!

I HAVE THE SAME PROBLEM, IF YOU KNOW WHAT IS TELL ME!!! MY CHARACTER MOVE OR ANIMATE, DONT DO 2 THINGS IN SAME TIME!!!