void FixedUpdate() { if (isServer) { buffholder.computeStats(); if (registerHit) { registerHit = false; if (attack) { RpcEndAttack(); } if (hp.change(-hitDamage)) { Destroy(gameObject); } else { RpcTakeHit(hitDirection * hitMag); } } if (abil1CD > 0) { abil1CD -= Time.fixedDeltaTime; } if (abil2CD > 0) { abil2CD -= Time.fixedDeltaTime; } } if (hasAuthority) { buffholder.computeStats(); ghost.renderCD(abil1CD, abil2CD); bool movement = true; Vector3 move = new Vector3(); switch (current) { #region states case PState.Free: if (!grounded) { current = PState.Air; movement = false; } if (inp.jump) //here { rb.AddForce(Vector3.up * jumpForce); current = PState.Air; } break; case PState.Air: if (grounded) { current = PState.Free; } else { movement = false; } break; case PState.KB: if (planeVel.magnitude <= KBRegain) { current = PState.Free; } //print(planeVel); movement = false; planeVel = planeVel.normalized * (planeVel.magnitude - KBDeteriorate * Time.fixedDeltaTime * (grounded ? 1 : 0.4f)); break; #endregion } if (movement) { #region movement if (inp.up) { move += new Vector3(0, 0, 1); } if (inp.down) { move += new Vector3(0, 0, -1); } if (inp.left) { move += new Vector3(-1, 0, 0); } if (inp.right) { move += new Vector3(1, 0, 0); } move.Normalize(); //rb.AddForce(move * moveForce * Time.fixedDeltaTime); //if(planeVel.magnitude >= maxSpeed) //{ // planeVel = planeVel.normalized * maxSpeed; //} if (!sprinting) { #region sprintS if (move != Vector3.zero) { if (lastMove == move) { sprintBuildCurrent += Time.fixedDeltaTime; } else { float diff = (move - lastMove).magnitude; if (diff > 1) { diff = 1; } Mathf.Pow(diff, 3); //print(diff); sprintBuildCurrent -= sprintChangeLoss * diff; if (sprintBuildCurrent < 0) { sprintBuildCurrent = 0; } } } lastMove = move; if (sprintBuildCurrent > sprintBuild) { //print("sprinting"); setSprint(true); } else { vis.CmdSprintAlpha(sprintPer); } #endregion } planeVel = ghost.spawnMutate(move) * maxSpeed * ((sprintSpeed) + 1); #endregion } Vector3 dif; switch (look) { case LookState.Free: dif = inp.target - transform.position; dif.y = 0; transform.rotation = Quaternion.LookRotation(dif); break; case LookState.Attacking: if (current != PState.Air) { dif = inp.target - transform.position; dif.y = 0; transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(dif), attackTurn * Time.fixedDeltaTime); } break; } if (look == LookState.Free && inp.attacking) { if (buffholder.buf("FullSprint") < 1) { setSprint(false); } if (inp.atk1) { look = LookState.Attacking; CmdAtk(attackType.basic, inp.groundTarget); } else if (inp.atk2) { look = LookState.Attacking; CmdAtk(attackType.heavy, inp.groundTarget); } else if (inp.abil1 && abil1CD <= 0) { look = LookState.Attacking; CmdAtk(attackType.abil1, inp.groundTarget); } else if (inp.abil2 && abil2CD <= 0) { look = LookState.Attacking; CmdAtk(attackType.abil2, inp.groundTarget); } } vis.CmdPropagate(); } }