Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Grendord · May 09, 2016 at 09:55 AM · unity 5collisiontrigger

Help with VR Controller Collider

Hey Guys,

I've been really stuck on a problem. I have a basic home in Unity3d and I am trying to add a lightswitch that the person can touch with their SteamVR Controller to turn on and off the lights. But I am not able to get an OnTriggerEnter event to fire when passing the controller through the lightswitch.

My lightswitch is a box collider. I've tried it with a rigid body and without. And as isKinematic and not.

I have a sphere collider and a rigidbody attached to the model under both Controller(left) and Controller(right) of the CameraRig Object.

Finally, I have the following Script Attached to the Models, but have also tried it on the switch.

 using UnityEngine;
 using System.Collections;

 public class SwitchCollision : MonoBehaviour {

     void OnCollisionEnter(Collision col)
     {
         Debug.Log("Switch Collision");
     }

     void OnTriggerEnter(Collider col) 
     {
         Debug.Log("Switch Trigger");
     }

 }

I can't get either to print. Can you see what I am missing?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image _dns_ · May 09, 2016 at 02:31 PM 0
Share

Hi, maybe colliders are on a different layer: check the layers the gameobjects are assigned to and the layer collision matrix in edit/projects settings/physics

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by TOOVISUAL · Feb 09, 2017 at 09:52 PM

This is a little buggy but if you add a character motor to the controller it will work. By buggy I mean if you put it on both hands it will error when you grab the same object with both hands. You will also want to bring in the size of the character motor and you dont need the character controller after you put it on, you only need the character motor.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TOOVISUAL · Feb 09, 2017 at 09:06 PM 0
Share

Also use this scrip and make sure your light is on on public and then also make sure you drag your light onto this script once you have attached it to your triggering collider.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class turnofflight : $$anonymous$$onoBehaviour
 {
 
     public Light light;
 
     void OnTriggerEnter()
     {
         light.enabled = false;
     }
 
     void OnTriggerLeave()
     {
         light.enabled = true;
     }
 }


Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

2d game end level with trigger and colission with trigger who to make a if condition 1 Answer

How do I make animation transitions a one-way street? 1 Answer

My trigger is called twice 1 Answer

OnTriggerEnter not working all the time. 2 Answers

Animate gameobject when collided with another gameobject using VRTK 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges