I have a small problem with controlling a character with a Character Controller when not using Input.GetAxis()
I prefere to use Input.GetKey() for all (or most) of my input, but the problem is when i don't use Input.GetAxis() the character falls to the ground but then just sort of disapeares after about half a second.
I don't understand why it would work with one but not the other.
var playerSpeed : float = 6.0;
var playerGravity : float = 20.0;
var playerJumpSpeed : float = 8.0;
private var playerMove : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
if(Input.GetKey(KeyCode.T))
playerMove = Vector3(0,0,1);
if(Input.GetKey(KeyCode.G))
playerMove = Vector3(0,0,-1);
if(Input.GetKey(KeyCode.F))
playerMove = Vector3(-1,0,0);
if(Input.GetKey(KeyCode.H))
playerMove = Vector3(1,0,0);
//Works with this line...but not the above code
//playerMove = Vector3(Input.GetAxis("Horizontal"), 0,Input.GetAxis("Vertical"));
playerMove = transform.TransformDirection(playerMove);
playerMove *= playerSpeed;
if(Input.GetKey(KeyCode.J)){
playerMove.y = playerJumpSpeed;
}
}
playerMove.y -= playerGravity * Time.deltaTime;
controller.Move(playerMove * Time.deltaTime);
}
It just seems strange that one will work, but the other will give me some very strange results :/
anyone else had problems like this or is it that you have to use Input.GetAxis()?