- Home /
3d platformer collider issues
Im currently working on a 3d puzzle platformer based around a cube, I've created 4 colliders on each corner of the cube in order to allow me to switch the camera on trigger as well as movement axis. However I have found when I jump through them the colliders seem to stop working. My current movement script is as follows:
var speed : float = 6.0; var jumpSpeed : float = 8.0; var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() { var controller : CharacterController = GetComponent(CharacterController); if (controller.isGrounded) { // We are grounded, so recalculate // move direction directly from axes
// var v = Input.GetAxisRaw("Horizontal");
// transform.Translate(Vector3.forward * (v/5));
// moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = Vector3(0, 0, Input.GetAxis("Horizontal"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
}
Any help would be greatly appreciated.
Your answer
Follow this Question
Related Questions
Jump height increasing after touching walls 0 Answers
Problem of gravity 1 Answer
Can't control movement while jumping 1 Answer
Top-Down Jumping (2D) 1 Answer
How do I create variable Jump Height for a platformer? 1 Answer