- Home /
Controls Are Acting Wierd?
When i try to control my 2D character it jumps up super high and doesn't come down. This happens when i use any of the control buttons like WASD, space and the arrow keys make it jump and it doesn't do anything else. please help on how to fix, is it because of my object is a plane (not a airplane but the object plane) I used the character motor Script and the CharacterController.Move skript here is the code. (I use javascript)
var speed : float = 10.0;
var jumpSpeed : float = 10.0;
var gravity : float = 1.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613112041im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Jumping while moving 1 Answer
In air movement troubles. 1 Answer
Jump to a specific frame in an animation 6 Answers
Trying to get accelerated jump speed. 2 Answers