Permalink
Browse files

Merge pull request #1936 from thestonefox/fix/2018.3-physx-errors

fix(physics): change collision detection mode for 2018.3
  • Loading branch information...
thestonefox committed Feb 1, 2019
2 parents e3ba379 + 17995f9 commit 50fba93606c7f67754984ced14505b3d6e5cd591
@@ -407,7 +407,11 @@ protected virtual void InitDoor()
doorRigidbody = actualDoor.AddComponent<Rigidbody>();
doorRigidbody.angularDrag = releasedFriction;
}
#if UNITY_2018_3_OR_NEWER
doorRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative; // otherwise door will not react to fast moving controller
#else
doorRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; // otherwise door will not react to fast moving controller
#endif
doorRigidbody.isKinematic = false; // in case nested door as already created this

doorHinge = actualDoor.GetComponent<HingeJoint>();
@@ -202,7 +202,11 @@ protected virtual void InitBody()
if (drawerRigidbody == null)
{
drawerRigidbody = gameObject.AddComponent<Rigidbody>();
#if UNITY_2018_3_OR_NEWER
drawerRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
#else
drawerRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
#endif
}
drawerRigidbody.isKinematic = false;

@@ -126,7 +126,11 @@ protected virtual void InitRigidbody()
if (leverRigidbody == null)
{
leverRigidbody = gameObject.AddComponent<Rigidbody>();
#if UNITY_2018_3_OR_NEWER
leverRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
#else
leverRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
#endif
leverRigidbody.angularDrag = releasedFriction; // otherwise lever will continue to move too far on its own
}
leverRigidbody.isKinematic = false;
@@ -148,7 +148,11 @@ protected virtual void Update()
protected override void ConfigueRigidbody()
{
SetRigidbodyGravity(false);
#if UNITY_2018_3_OR_NEWER
SetRigidbodyCollisionDetectionMode(CollisionDetectionMode.ContinuousSpeculative);
#else
SetRigidbodyCollisionDetectionMode(CollisionDetectionMode.ContinuousDynamic);
#endif
SetRigidbodyConstraints(RigidbodyConstraints.FreezeRotation);
}

@@ -234,7 +234,11 @@ protected virtual void Update()
protected override void ConfigueRigidbody()
{
SetRigidbodyGravity(false);
#if UNITY_2018_3_OR_NEWER
controlRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
#else
controlRigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
#endif
controlRigidbody.constraints = RigidbodyConstraints.FreezeRotation;
}

@@ -534,7 +534,11 @@ protected virtual void CreateTouchRigidBody()
touchRigidBody.isKinematic = true;
touchRigidBody.useGravity = false;
touchRigidBody.constraints = RigidbodyConstraints.FreezeAll;
#if UNITY_2018_3_OR_NEWER
touchRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
#else
touchRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
#endif
}

protected virtual void EmitControllerRigidbodyEvent(bool state)
@@ -594,7 +594,11 @@ protected virtual void CreateObjectInteractor()
Rigidbody objectInteratorRigidBody = objectInteractorAttachPoint.AddComponent<Rigidbody>();
objectInteratorRigidBody.isKinematic = true;
objectInteratorRigidBody.freezeRotation = true;
#if UNITY_2018_3_OR_NEWER
objectInteratorRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
#else
objectInteratorRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
#endif
VRTK_PlayerObject.SetPlayerObject(objectInteractorAttachPoint, VRTK_PlayerObject.ObjectTypes.Pointer);
}

0 comments on commit 50fba93

Please sign in to comment.