void IEntity.EUpdate(float delta) { isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask); if (isGrounded && velocity.y < 0) { velocity.y = -2f; spatial.getFloorState(transform.position.x, transform.position.z, gameObject); } float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); Vector3 move = transform.right * x + transform.forward * z; controller.Move(move * speed * Time.deltaTime); if (Input.GetButtonDown("Jump") && isGrounded) { velocity.y = Mathf.Sqrt(jumpHeight * -2f * Physics.gravity.y); } if (!flyMode) { velocity += Physics.gravity * Time.deltaTime; controller.Move(velocity * Time.deltaTime); } }
void Update() { spatial.getFloorState(transform.position.x, transform.position.z, gameObject); }