-
Notifications
You must be signed in to change notification settings - Fork 3
8. Adding game‐specific mod code
Every time you use UGVR you are loading an entire copy of all the Injector's code. While this does require more space (about 50mb per game) then one universal solution that just resides one place, the side benefit is that a modder who is a fan of a particular game can completely customize UGVR's code for that game and distribute a custom version, as all the files are editable in notepad++ or in Godot itself (I use Godot 4.2 to attempt to ensure as much compatibility as possible).
Most Godot games create logs ("godot.log") in your app user data. If you raise your secondary hand over your head and press the top face button (B or Y) this will cause a printout of all game elements that exist in the current scene to this log file. By scrolling through and experimenting you can find elements that you may want to try reparenting to your controller(s).
The xrscene.gd in xr_injector folder is usually the key file to focus on when plugging in game specific code as it retains references to all XR components in the scene. Also _process(delta) can be used to hook actions that will run each frame, and ready() can be used to hook actions used at first run.
UGVR's scene.gd contained in the xr_injector folder has examples of game-specific code that can be run for Road to Vostok demo, Total Abstraction Rewind, CRUEL and Beton. These are enabled at lines 222-225 by marking the relevant line as true, then you can find the accompanying functions near the end of the file.
The way these additions work is their code is executed when Godot's _process(delta) function runs, which is basically every frame. They then work to find and reparent certain game elements to the controllers like weapons.
You could create similar code for basically any game, at least those written in gdscript rather than C#.
Soon I will release a version of UGVR as a mod for the Road to Vostok modloader. This allows UGVR to be used alongside other game mods people are creating (assuming the modified files do not conflict). See https://modworkshop.net/mod/49779 for the Road to Vostok modloader.