I am making a ninja game and i made a pretty cool ninja using the basic objects in unity because i don't have a graphic design program (or the money for one) to do it. now because the colliders are clashing when i click the forward button i fly in the air. i tried changing the size of the the colliders so they were not touching and moving the objects so they did not touch the other game objects but i still slowly move up. this is my walking script.
var speed= 6.0;
var rotateSpeed = 3.0;
var runningSpeed= 10.0;
var strafeSpeed = 0.1;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
Try using transform.forward rather than TransformDirection(Vector3.forward). You might want to consider putting it directly in the SimpleMove or creating another variable other than "forward" (I get nervous when using variable names that are already in use on other Components)
Also, your character will move at different speeds depending on your framerate. Try multiplying your move by Time.deltaTime in order to keep the movement framerate-independent.
EDIT
var speed: float= 6.0;
var rotateSpeed: float = 3.0;
var cControl: CharacterController;
function Awake (){
cControl = GetComponent(CharacterController);
}
function Update ()
{
var direction: Vector3 = Vector3 (0, Input.GetAxis ("Horizontal") * rotateSpeed* Time.deltaTime, 0);
var movementSpeed: float = Input.GetAxis ("Vertical")*speed*Time.deltaTime;
transform.Rotate(direction);
cControl.SimpleMove(transform.forward*movementSpeed);
}
Try the above. Let me know if you still have the same problem... there's one more thing I can think of trying...
I have also an answer, that it more Easy.
In the game I am creating now, i used a game object. I did so the game object was to be a prebab or what the name is.
And so, i added a camera, a characher controller. And now It can be constrolled as you want to.