- Home /
Character Controller acting strange
First, I'm an incredible newb when it comes to Unity. That being said, I purchased a book on Unity Game Development. In it, there is an FPSWalker script. I thought I'd adapt it a bit in order to make a side-scrolling, 2.5D "Megaman" style game. What's weird about it is that although the code works beautifully for a simple Capsule gameobject, it won't work at all for a complex, animated model I imported. I have no clue why that's the case. Here's my code...
var speed = 6.0; var jumpSpeed = 8.0; var gravity = 20.0;
private var moveDirection = Vector2.zero; private var grounded : boolean = false; var controller : CharacterController;
function Start() { var controller : CharacterController = GetComponent(CharacterController);
}
function fixedUpdate() { if (grounded) { moveDirection = new Vector2(Input.GetAxis("Horizontal"), 0); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed;
if (Input.GetButton("Jump")) {
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags & CollisionFlags.CollidedBelow) != 0;
} @script RequireComponent(CharacterController)
Any help would be great. I'm really trying to wrap my head around this. It seems like a very powerful tool :-)
Answer by Kith · Mar 21, 2010 at 05:51 AM
Ugh nevermind, fixedUpdated needed to be "FixedUpdate" -.-
Your answer
Follow this Question
Related Questions
Google sketchup models in Unity 3 Answers
Objects or Meshes? 1 Answer
How to create 3d models for game and how to add them to game 2 Answers
Animating guns that you can pickup 0 Answers