|
- var speed = 6.0;
- var jumpSpeed = 8.0;
- var gravity = 0;
- private var moveDirection = Vector3.zero;
- private var grounded : boolean = false;
- function FixedUpdate() {
- my=moveDirection.y;
- moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
- moveDirection = transform.TransformDirection(moveDirection);
- if (grounded) {
- moveDirection *= speed;
- } else {
- moveDirection *= speed+transform.position.y/5;
- moveDirection.y=my;
- }
- if(Input.GetKey ("e")) {
- transform.Translate(0, -1, 0);
- }
- if (Input.GetKey ("q") ) {
- transform.Translate(0, 1, 0);
- }
- if(Input.GetKey("left shift")) {
- speed=6*5;
- } else {
- speed=6;
- }
- moveDirection.y -= gravity * Time.deltaTime;
- moveDirection.z -= gravity * Time.deltaTime;
- var controller : CharacterController = GetComponent(CharacterController);
- var flags = controller.Move(moveDirection * Time.deltaTime);
- grounded = (flags & CollisionFlags.CollidedBelow) != 0;
- }
- @script RequireComponent(CharacterController)
- private var myWalker: FPSWalker=null;
- var maxHeight: float=250;
- function Start () {
- myWalker = gameObject.GetComponent(FPSWalker);
- }
- @script RequireComponent(FPSWalker)
复制代码 |
|