private void Start() { world = NetBridge.Instance.world; transform.position = world.GetPlayerSpawn(); if (isLocalPlayer || isServer) { chatUIManager.enabled = true; } if (!isLocalPlayer) { cam.enabled = false; ls.enabled = false; Destroy(playerUI); renderer.material.color = myColor; nameTag.text = charName; } else { myColor = NetBridge.Instance.localPlayerColor; CmdSetColor(myColor); charName = NetBridge.Instance.avatarName; CmdSetName(charName); playerUI.SetActive(true); lastVerifiedState.pos = transform.position; lastVerifiedState.eulerAvatar = avatar.eulerAngles; lastVerifiedState.eulerCam = camTrans.eulerAngles; lastVerifiedState.yvel = yvel; lastVerifiedState.id = packetId; lastVerifiedState.blockType = blockType; } }
private void ProcessInputAndMotion(MVCInput input, bool doInteractionInput = true) { if (!cc.isGrounded) { yvel -= gravForce * input.dt; } else if (input.jump) { yvel = jumpForce; } else { yvel = 0; } Vector3 move = avatar.up * yvel * input.dt; move += avatar.forward * input.moveZ; move += avatar.right * input.moveX; cc.Move(move); if (avatar.position.y < worldBottom) { avatar.position = world.GetPlayerSpawn(); } avatar.eulerAngles += Vector3.up * input.rotYaw; Vector3 camAng = camTrans.eulerAngles; camAng += Vector3.right * input.rotPitch; if (camAng.x > 180.0f) { camAng.x = Mathf.Clamp(camAng.x, camPitchClamp1, 360.0f); } else if (camAng.x < 10.0f) { camAng.x = Mathf.Clamp(camAng.x, -10.0f, 10.0f); } else { camAng.x = Mathf.Clamp(camAng.x, 0.0f, camPitchClamp2); } camTrans.eulerAngles = camAng; blockType += input.blockTypeChange; while (blockType > numOfBlockTypes || blockType < 1 || !NetBridge.Instance.blockTypeManager.IsBlockPlacable(blockType)) { if (blockType > numOfBlockTypes) { blockType = 1; } else if (blockType < 1) { blockType = numOfBlockTypes; } if (!NetBridge.Instance.blockTypeManager.IsBlockPlacable(blockType)) { blockType += input.blockTypeChange; } } if (isLocalPlayer && input.blockTypeChange != 0) { UIBridge.Instance.OnBlockSelectionChange(blockType); } if (doInteractionInput) { ProcessInteractionInput(input); } }