- Home /
C# script for highlighting certain objects when the VR Controller is pointed at them?
I have a failed script I already asked about, but I think I should start over.
Issues I am having:
If I make the script for the objects to be highlighted, how do I make the commands to detect when the VR controller touchpad is pressed/being pointed at them?
If I make the script for the controller, how could I make it know which objects to be highlighted, if I use a layer then probably all of the objects will highlight if even one is registered. So perhaps I could add multiple layers and parameters to only highlight objects in the applicable layers but also only the ones which are pointed at.
stuck
Last option would be to make 2 scripts and somehow make them connected, where if the controller touchpad is pressed and pointed at the object, the object's own script to be highlighted will be triggered.
I am using the SteamVR sdk for HTC Vive, and I am not asking for any fancy shaders or whatnot. For this goal to highlight objects, a simple material/color change will suffice.
I assume it would be similar to a simple $$anonymous$$ouseOver method which changes the material color, but working the VR controllers into the script ins$$anonymous$$d of using the mouse is really tricky.
I actually found a default highlight shader, so the script would have to toggle the shaders when the event occurs. I could probably manage that, however I still do not understand how to trigger the event by pointing the VR Controller at the object while pressing the touchpad.
Your answer
![](https://koobas.hobune.stream/wayback/20220612144613im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Raycasting out from a first person controller 1 Answer
How to push away an object raycast c# 3 Answers