void Update() { Ray ray = new Ray(transform.position, Vector3.down); if (!Physics.Raycast(ray)) { roomlogic.Respawn(transform); } if (controller.isGrounded) { grounded = true; } else { grounded = false; } CheckState(); CheckInput(); if (controller.isGrounded) { ver = -input.GetAxis("Horizontal"); hor = input.GetAxis("Vertical"); if (Mathf.Abs(ver) > 0.1f && Mathf.Abs(hor) > 0.1f) { adjvar = -0.701f; } else { adjvar = -1f; } moveDirection = new Vector3(hor * adjvar, -1f, ver * adjvar); moveDirection = transform.TransformDirection(moveDirection); //Debug.Log(moveDirection); moveDirection *= speed; if (input.GetKeyDown("Jump")) { if (state == 0) { moveDirection.y = jumpSpeed; } else if (state == 1) { state = 0; } else if (state == 2) { state = 1; } } } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); SetPlValues(); //Debug.Log(moveDirection); }