ValveSoftware / steamvr_unity_plugin

SteamVR Unity Plugin - Documentation at: https://valvesoftware.github.io/steamvr_unity_plugin/
BSD 3-Clause "New" or "Revised" License
1.02k stars 254 forks source link

NullReferenceException: Object reference not set to an instance of an object #1112

Open CrisChenYingyan opened 1 month ago

CrisChenYingyan commented 1 month ago

I have configured the variable SteamVR_Action_Boolean MovePress to detect whether the trackpad on the HTC Vive controller is pressed. I have also bound this action to the controller using SteamVR input. Additionally, I set movePress = SteamVR Actions.default.m_MovePress. However, when I check the status of MovePress using if (movePress.GetStateDown(SteamVR_Input_Sources.Any)), I encounter the following error.

NullReferenceException: Object reference not set to an instance of an object Valve.VR.SteamVR_Action_Boolean_Source.UpdateValue () (at Assets/SteamVR/Input/SteamVR_Action_Boolean.cs:415) Valve.VR.SteamVR_Action_In_Source_Map1[SourceElement].ForceAddSourceToUpdateList (Valve.VR.SteamVR_Input_Sources inputSource) (at Assets/SteamVR/Input/SteamVR_Action_In.cs:217) Valve.VR.SteamVR_Action_In_Source_Map1[SourceElement].OnAccessSource (Valve.VR.SteamVR_Input_Sources inputSource) (at Assets/SteamVR/Input/SteamVR_Action_In.cs:192) Valve.VR.SteamVR_Action_Source_Map1[SourceElement].GetSourceElementForIndexer (Valve.VR.SteamVR_Input_Sources inputSource) (at Assets/SteamVR/Input/SteamVR_Action.cs:607) Valve.VR.SteamVR_Action_Source_Map1[SourceElement].get_Item (Valve.VR.SteamVR_Input_Sources inputSource) (at Assets/SteamVR/Input/SteamVR_Action.cs:573) Valve.VR.SteamVR_Action_Boolean.GetStateDown (Valve.VR.SteamVR_Input_Sources inputSource) (at Assets/SteamVR/Input/SteamVR_Action_Boolean.cs:80) PlayerController.FixedUpdate () (at Assets/Scripts/PlayerController.cs:39)

How should I modify it?

Hatercobzz commented 6 days ago

Have got the solution???? I need it urgently

CrisChenYingyan commented 6 days ago

I have currently resolved this issue.  The way I handled it is as follows: After opening the Unity project, open the Steam VR input options, then open the binding operation interface for the VR controller (at this point, there should be a message indicating that VR has been successfully initialized), and then you can run the project normally. I believe this issue occurs because the VR controllers and headset do not have enough time to initialize and connect when running the program. Therefore, you can prompt the initialization of the controllers and headset by editing the controller settings.  This is my approach. Good luck!  

他者 @.***

 

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2024年6月25日(星期二) 晚上6:33 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [ValveSoftware/steamvr_unity_plugin] NullReferenceException: Object reference not set to an instance of an object (Issue #1112)

Have got the solution???? I need it urgently

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>