void FixedUpdate() { DRV.velocitySmoothTime = velocitySmoothTime; DRQ.velocitySmoothTime = velocitySmoothTime; DRV.followTime = followTime; DRQ.followTime = followTime; if (!photonView.IsMine) { body.isKinematic = true; if (DRV.isReady) { body.transform.position = DRV.Update(Time.fixedDeltaTime); body.velocity = DRV.velocity; } if (DRQ.isReady) { body.transform.rotation = DRQ.Update(Time.fixedDeltaTime); body.angularVelocity = DRQ.lastAngularVelocity; } if (body.useGravity) { body.AddForce(-body.mass * Physics.gravity); } } else { body.isKinematic = false; } }
void FixedUpdate() { if (!firstTake && !photonView.IsMine) { if (DRPlayerRootV.isReady) { Vector3 playerPosition = DRPlayerRootV.Update(Time.fixedDeltaTime); playerRoot.position = attachedTransform ? attachedTransform.TransformPoint(playerPosition) : playerPosition; } if (DRPlayerRootQ.isReady) { Quaternion playerRotation = DRPlayerRootQ.Update(Time.fixedDeltaTime); playerRoot.rotation = attachedTransform ? attachedTransform.rotation * playerRotation : playerRotation; } for (int i = 0; i < riggingTransforms.Length; ++i) { if (DRRiggingV[i].isReady) { riggingTransforms[i].position = fromLocal(DRRiggingV[i].Update(Time.fixedDeltaTime)); } if (DRRiggingQ[i].isReady) { riggingTransforms[i].rotation = fromLocal(DRRiggingQ[i].Update(Time.fixedDeltaTime)); } } } }
void FixedUpdate() { colLevel = _colLevel; _colLevel = ColLevel.None; if (body.IsSleeping()) { colLevel = ColLevel.GroundOrSleep; } float E = .5f * body.velocity.sqrMagnitude + .5f * Vector3.Dot(body.angularVelocity, ApplyTensor(body.angularVelocity, body.inertiaTensor, body.rotation * body.inertiaTensorRotation)) / body.mass; if (isActiveAndEnabled && PhotonNetwork.IsConnectedAndReady) { if (isOtherPlayerPickup) { if (isLocalPlayerPickup) { onOtherPlayerTake.Invoke(); } } else if (isLocalPlayerPickup) { //Let Grabable Script handle the all } else if (photonView.IsMine) { if (colLevel == ColLevel.GroundOrSleep) { if (E < Physics.sleepThreshold) { if (!PhotonNetwork.IsMasterClient) { //send stopped body Vector3 position = body.position; Quaternion rotation = body.rotation; ToAttached(ref position, ref rotation); DRV.NetworkUpdate(position, Vector3.zero, 0, true); DRQ.NetworkUpdate(rotation, Vector3.zero, 0, true); useDR = true; TransfreOwnershipBrutal(PhotonNetwork.MasterClient); } } } if (colLevel == ColLevel.OtherOwned) { if (!PhotonNetwork.IsMasterClient) { //send stopped body Vector3 position = body.position; Quaternion rotation = body.rotation; ToAttached(ref position, ref rotation); DRV.NetworkUpdate(position, Vector3.zero, 0, true); DRQ.NetworkUpdate(rotation, Vector3.zero, 0, true); useDR = true; TransfreOwnershipBrutal(PhotonNetwork.MasterClient); } } } else { if (colLevel == ColLevel.LocalPickedup) { TransfreOwnershipBrutal(PhotonNetwork.LocalPlayer); } } } if (photonView.IsMine) { useDR = false; } if (useDR) { if (DRV.isReady && DRQ.isReady) { Vector3 position = DRV.Update(Time.fixedDeltaTime); Quaternion rotation = DRQ.Update(Time.fixedDeltaTime); Vector3 velocity = DRV.velocity; Vector3 angularVelocity = DRQ.angularVelocity; FromAttached(ref position, ref rotation, ref velocity, ref angularVelocity); body.MovePosition(position); body.velocity = velocity; body.MoveRotation(rotation); body.angularVelocity = angularVelocity; } if (body.useGravity) { body.AddForce(-body.mass * Physics.gravity); } } //body.isKinematic = useDR;//TODOTODOTODO Do it after teleportation to wakeup stacked objects //DebugColor(); }