I know it's possible, as the game has underwater ambient sounds. However, even after searching every file (yes, even in the game engine) I have not been able to figure it out. The only finding was in lua/ge/extensions/core/sounds.lua: Code: local camObj = getCamera() camObj = (camObj and Sim.upcast(camObj)) or camObj globalParams:setParameterValue("g_CamFree", commands.isFreeCamera() and 1 or 0) globalParams:setParameterValue("g_CamUnderwater", (camObj and camObj:isCameraUnderwater() and 1) or 0) It seems to be using a isCameraUnderwater() function, however I am unable to call it. This command: Code: obj:queueGameEngineLua("local camObj = getCamera() if (camObj and camObj:isCameraUnderwater() and 1) then camIsUnderwater = true else camIsUnderwater = false end") Results in: Oh, and I have not found the function isCameraUnderwater() anywhere other than in sounds.lua
Idk maybe use this code Code: camObj = (camObj and Sim.upcast(camObj)) or camObj This code has been used in the sounds.lua but not in yours, so probably it's the problem Also, why you used obj:queueGameEngineLua in your code?
That did fix it, thanks! To execute the code in the game engine, as I cannot access the core stuff from the vehicle lua. --- Post updated --- Alright, so I got it to work! https://cdn.discordapp.com/attachme...856420560936/BeamNG_2021.09.30-19.52_Trim.mp4 The command to check if the camera is underwater is: Code: obj:queueGameEngineLua('local camObj = getCamera() camObj = (camObj and Sim.upcast(camObj)) or camObj if (camObj and camObj:isCameraUnderwater() and 1) then be:getPlayerVehicle(0):queueLuaCommand("camIsUnderwater = true") else be:getPlayerVehicle(0):queueLuaCommand("camIsUnderwater = false") end') camIsUnderwater is set as a global for use in the vehicle.