private void Update() { _colliderObject.transform.rotation = Quaternion.identity; //UpdateTestBinds (); UpdateMoveData(); // Previous movement code Vector3 positionalMovement = transform.position - prevPosition; transform.position = prevPosition; moveData.origin += positionalMovement; // Triggers if (numberOfTriggers != triggers.Count) { numberOfTriggers = triggers.Count; underwater = false; triggers.RemoveAll(item => item == null); foreach (Collider trigger in triggers) { if (trigger == null) { continue; } if (trigger.GetComponentInParent <Water> ()) { underwater = true; } } } _moveData.cameraUnderwater = _cameraWaterCheck.IsUnderwater(); _cameraWaterCheckObject.transform.position = viewTransform.position; moveData.underwater = underwater; if (allowCrouch) { _controller.Crouch(this, movementConfig, Time.deltaTime); } _controller.ProcessMovement(this, movementConfig, Time.deltaTime); transform.position = moveData.origin; prevPosition = transform.position; _colliderObject.transform.rotation = Quaternion.identity; }
private void Update() { if (moveWithGround) { if (groundObject) { transform.parent = groundObject.transform; } else { transform.parent = null; } //HACKHACK: we don't want the player to rotate on these. Is there a better way to do this? Quaternion temp = transform.rotation; temp.x = 0; temp.z = 0; transform.rotation = temp; } _colliderObject.transform.rotation = Quaternion.identity; //UpdateTestBinds (); UpdateMoveData(); // Previous movement code Vector3 positionalMovement = transform.position - prevPosition; transform.position = prevPosition; moveData.origin += positionalMovement; // Triggers if (numberOfTriggers != triggers.Count) { numberOfTriggers = triggers.Count; underwater = false; triggers.RemoveAll(item => item == null); foreach (Collider trigger in triggers) { if (trigger == null) { continue; } if (trigger.GetComponentInParent <Water> ()) { underwater = true; } } } _moveData.cameraUnderwater = _cameraWaterCheck.IsUnderwater(); _cameraWaterCheckObject.transform.position = viewTransform.position; moveData.underwater = underwater; if (allowCrouch) { _controller.Crouch(this, movementConfig, Time.deltaTime); } _controller.ProcessMovement(this, movementConfig, Time.deltaTime); transform.position = moveData.origin; prevPosition = transform.position; _colliderObject.transform.rotation = Quaternion.identity; }
private void Update() { //Debug.Log("ID: "+netId+" hasAuthority: "+hasAuthority); if (!isLocalPlayer) { return; } //Debug.Log("ID: " + netId + " is local player"); _colliderObject.transform.rotation = Quaternion.identity; UpdateTestBinds(); UpdateMoveData(); // Previous movement code Vector3 positionalMovement = transform.position - prevPosition; transform.position = prevPosition; moveData.origin += positionalMovement; // Triggers if (numberOfTriggers != triggers.Count) { numberOfTriggers = triggers.Count; underwater = false; triggers.RemoveAll(item => item == null); foreach (Collider trigger in triggers) { if (trigger == null) { continue; } if (trigger.GetComponentInParent <Water> ()) { underwater = true; } } } _moveData.cameraUnderwater = _cameraWaterCheck.IsUnderwater(); _cameraWaterCheckObject.transform.position = viewTransform.position; moveData.underwater = underwater; if (allowCrouch) { _controller.Crouch(this, movementConfig, Time.deltaTime); } _controller.ProcessMovement(this, movementConfig, Time.deltaTime); if (lives > 0) { if (moveData.velocity.y == 0f) { time_grounded += Time.deltaTime; } if (time_grounded > Max_Time_Grounded) { Death(); } } transform.position = moveData.origin; prevPosition = transform.position; _colliderObject.transform.rotation = Quaternion.identity; Speed_Text.text = "Speed: " + _controller.speed.ToString("F2"); Grounded_Text.text = "Time to death: " + (Max_Time_Grounded - time_grounded).ToString("F2"); }