private void OnSynchPosition(SynchedPosition position) { if (this.isLocalPlayer == false) { this.synchedPositions.Enqueue(position); } this.targetLerpTime = position.t - this.lerpDelay; }
// Update is called once per frame void Update() { if (this.isLocalPlayer) { Fire(); } else { // Interpolate position while (this.synchedPositions.Count > 0 && this.synchedPositions.Peek().t <= this.targetLerpTime) { this.interpolateFromSynchedPosition = this.synchedPositions.Dequeue(); } if (this.synchedPositions.Count > 0) { float t = Mathf.InverseLerp(this.interpolateFromSynchedPosition.t, this.synchedPositions.Peek().t, this.targetLerpTime); this.transform.position = Vector3.Lerp(this.interpolateFromSynchedPosition.position, this.synchedPositions.Peek().position, t); this.transform.rotation = Quaternion.Slerp(this.interpolateFromSynchedPosition.rotation, this.synchedPositions.Peek().rotation, t); } else { this.transform.position = this.interpolateFromSynchedPosition.position; this.transform.rotation = this.interpolateFromSynchedPosition.rotation; } this.targetLerpTime += Time.deltaTime; if (this.m_magic != null) { this.m_magic.transform.position = this.transform.position; } // State UpdateState(this.synchedState); } if (this.m_state == Player.state.pizza) { if (this.synchedHasPizza) { //Show arms and pizza transform.Find("wizard_arm").gameObject.SetActive(true); transform.Find("wizard_arm_2").gameObject.SetActive(true); transform.Find("pizza").gameObject.SetActive(true); } else { transform.Find("wizard_arm").gameObject.SetActive(false); transform.Find("wizard_arm_2").gameObject.SetActive(false); transform.Find("pizza").gameObject.SetActive(false); } } }
private void CmdUpdatePosition(SynchedPosition position) { this.synchedPosition = position; }
private void Update() { if (this.isLocalPlayer) { this.magic = TestPlayer.MagicType.None; if (Input.GetKey(this.rockKey)) { this.magic = MagicType.Rock; } else if (Input.GetKey(this.paperKey)) { this.magic = MagicType.Paper; } else if (Input.GetKey(this.scissorsKey)) { this.magic = MagicType.Scissors; } CmdUpdateMagic(this.magic); } else { // Interpolate position while (this.synchedPositions.Count > 0 && this.synchedPositions.Peek().t <= this.targetLerpTime) { this.interpolateFromSynchedPosition = this.synchedPositions.Dequeue(); } if (this.synchedPositions.Count > 0) { float t = Mathf.InverseLerp(this.interpolateFromSynchedPosition.t, this.synchedPositions.Peek().t, this.targetLerpTime); this.transform.position = Vector3.Lerp(this.interpolateFromSynchedPosition.position, this.synchedPositions.Peek().position, t); } else { this.transform.position = this.interpolateFromSynchedPosition.position; } this.targetLerpTime += Time.deltaTime; // Magic this.magic = this.synchedMagic; } switch (this.magic) { case MagicType.None: this.material.color = Color.white; break; case MagicType.Paper: this.material.color = this.paperColour; break; case MagicType.Rock: this.material.color = this.rockColour; break; case MagicType.Scissors: this.material.color = this.scissorsColour; break; } }
// Update is called once per frame void Update() { if (this.isLocalPlayer) { Fire(); } else { // Interpolate position while (this.synchedPositions.Count > 0 && this.synchedPositions.Peek().t <= this.targetLerpTime) { this.interpolateFromSynchedPosition = this.synchedPositions.Dequeue(); } if (this.synchedPositions.Count > 0) { float t = Mathf.InverseLerp(this.interpolateFromSynchedPosition.t, this.synchedPositions.Peek().t, this.targetLerpTime); this.transform.position = Vector3.Lerp(this.interpolateFromSynchedPosition.position, this.synchedPositions.Peek().position, t); this.transform.rotation = Quaternion.Slerp(this.interpolateFromSynchedPosition.rotation, this.synchedPositions.Peek().rotation, t); } else { this.transform.position = this.interpolateFromSynchedPosition.position; this.transform.rotation = this.interpolateFromSynchedPosition.rotation; } this.targetLerpTime += Time.deltaTime; if (this.m_magic != null) { this.m_magic.transform.position = this.transform.position; } // State UpdateState(this.synchedState); } if (this.m_state == Player.state.pizza) { if (this.synchedHasPizza) { //Show arms and pizza transform.Find("wizard_arm").gameObject.SetActive(true); transform.Find("wizard_arm_2").gameObject.SetActive(true); transform.Find("pizza").gameObject.SetActive(true); } else { transform.Find("wizard_arm").gameObject.SetActive(false); transform.Find("wizard_arm_2").gameObject.SetActive(false); transform.Find("pizza").gameObject.SetActive(false); } } }
private void OnSynchPosition(SynchedPosition position) { if (this.isLocalPlayer == false) { this.synchedPositions.Enqueue(position); } this.targetLerpTime = position.t - this.lerpDelay; }
private void CmdUpdatePosition(SynchedPosition position) { this.synchedPosition = position; }
private void Update() { if (this.isLocalPlayer) { this.magic = TestPlayer.MagicType.None; if (Input.GetKey(this.rockKey)) { this.magic = MagicType.Rock; } else if (Input.GetKey(this.paperKey)) { this.magic = MagicType.Paper; } else if (Input.GetKey(this.scissorsKey)) { this.magic = MagicType.Scissors; } CmdUpdateMagic(this.magic); } else { // Interpolate position while (this.synchedPositions.Count > 0 && this.synchedPositions.Peek().t <= this.targetLerpTime) { this.interpolateFromSynchedPosition = this.synchedPositions.Dequeue(); } if (this.synchedPositions.Count > 0) { float t = Mathf.InverseLerp(this.interpolateFromSynchedPosition.t, this.synchedPositions.Peek().t, this.targetLerpTime); this.transform.position = Vector3.Lerp(this.interpolateFromSynchedPosition.position, this.synchedPositions.Peek().position, t); } else { this.transform.position = this.interpolateFromSynchedPosition.position; } this.targetLerpTime += Time.deltaTime; // Magic this.magic = this.synchedMagic; } switch (this.magic) { case MagicType.None: this.material.color = Color.white; break; case MagicType.Paper: this.material.color = this.paperColour; break; case MagicType.Rock: this.material.color = this.rockColour; break; case MagicType.Scissors: this.material.color = this.scissorsColour; break; } }