Skip to content

Commit

Permalink
fix(Interaction): ensure controller collider is created correctly
Browse files Browse the repository at this point in the history
The controller collider would not be created if a
`customRigidbodyObject` was given or if the scene was reloaded
because the object was just being assigned and not instantiated.

This has now been fixed to ensure it gets correctly created.
  • Loading branch information
thestonefox committed Aug 14, 2016
1 parent 0618f37 commit 6c6c232
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Assets/SteamVR_Unity_Toolkit/Scripts/VRTK_InteractTouch.cs
Expand Up @@ -39,6 +39,7 @@ public class VRTK_InteractTouch : MonoBehaviour
private bool customRigidBody;
private bool customColliderCollection;
private Rigidbody touchRigidBody;
private Object defaultColliderPrefab;

public virtual void OnControllerTouchInteractableObject(ObjectInteractEventArgs e)
{
Expand Down Expand Up @@ -139,6 +140,7 @@ private void Awake()
Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller);
customRigidBody = false;
customColliderCollection = false;
defaultColliderPrefab = Resources.Load("ControllerColliders/HTCVive");
}

private void OnEnable()
Expand Down Expand Up @@ -290,14 +292,15 @@ private void DestroyTouchRigidBody()

private void CreateTouchCollider()
{
controllerCollisionDetector = customRigidbodyObject;
customColliderCollection = true;
if (customRigidbodyObject == null)
{
var colliderGO = Instantiate(Resources.Load("ControllerColliders/HTCVive") as GameObject, transform.position, transform.rotation) as GameObject;
colliderGO.transform.SetParent(transform);
colliderGO.name = "ControllerColliders";
controllerCollisionDetector = colliderGO;
controllerCollisionDetector = Instantiate(defaultColliderPrefab, transform.position, transform.rotation) as GameObject;
controllerCollisionDetector.transform.SetParent(transform);
controllerCollisionDetector.name = "ControllerColliders";
customColliderCollection = false;
} else
{
controllerCollisionDetector = Instantiate(customRigidbodyObject, transform.position, transform.rotation) as GameObject;
customColliderCollection = true;
}
}
Expand Down

0 comments on commit 6c6c232

Please sign in to comment.