User talk:Barash
Jump to navigation
Jump to search
I am a novice developer, trying to understand how to get the object that the player is looking at using the example of a specific plugin.
I found a plug-in on the network that allows you to open doors when executing a command, in it I was interested in the implementation of obtaining data about the object that the player is looking at, but when I try to execute the command I get an error
if (PhysicsUtility.raycast(new Ray(look.aim.position, look.aim.forward), out RaycastHit hit, Mathf.Infinity, RayMasks.BARRICADE_INTERACT)) { InteractableDoorHinge hinge = hit.transform.GetComponent<InteractableDoorHinge>(); if (hinge != null) { InteractableDoor door = hinge.door; bool open = !door.isOpen; Util.ToggleDoor(door, open); UnturnedChat.Say(caller, Util.Translate("door_toggle", open ? "opened" : "closed")); if (open && BreakAndEnter.instance.Configuration.Instance.AutoCloseDoors) BreakAndEnter.instance.AutoCloseDoor(door); } else UnturnedChat.Say(caller, Util.Translate("invalid_door")); } else UnturnedChat.Say(caller, Util.Translate("no_object"));'' error: An error occured while executing storage []: System.NullReferenceException: Object reference not set to an instance of an object at SDG.Unturned.VolumeManager`2[TVolume,TManager].Raycast (UnityEngine.Ray ray, UnityEngine.RaycastHit& hitInfo, TVolume& hitVolume, System.Single maxDistance) [0x0002d] in <92cd15f8f69f4be2b774ed1e0c34e0c2>:0
I suppose that I have something wrong with the conditional construction, namely an error due to RayMasks.BARRICADE_INTERACT, but I didn’t find the documentation, so I can’t think of anything with a solution, please help
- Hey, Barash! The wiki's talk pages should be used for wiki-related purposes -- not troubleshooting, debugging, modding help, etc. You should use a more relevant community instead, such as our forums. https://forum.smartlydressedgames.com/ —MoltonMontro (talk) 21:01, May 3, 2023 (UTC)