Garry's Mod

Garry's Mod

[ArcVR] Fixed (OUTDATED)
SophieBaybey Jan 14, 2021 @ 7:15pm
ArcVR SWEP Tutorial
Pasting this here, only because nobody else has. Text all acquired from shared.lua file

-- Okay, listen up, because I'm going to take you on a tutorial to make VR weapons.
-- Before you even touch this file, you will need the following:
-- - A VR headset. I mean, you could technically do this without one, but what'd be the point?
-- - A model you want to convert. If this is already rigged then you don't need ANYTHING else.
-- - Blender: To do the rigging.
-- - Blender Source Tools: To import/export .SMD source models.
-- - Crowbar (For Source): To extract stuff and compile .QC files.
-- - Patience or a good internet connection: You will be looking up a *lot* of ♥♥♥♥.

-- And a basic understanding of:
-- - Blender. Watch a tutorial if you don't know anything about it.
-- - Source Engine. Understanding can only be acquired through experience.

-- Step 0: Annoying Hurdles
-- Crowbar needs to be set up if your games are not in the default C: directory Steam uses.
-- Blender Source Tools needs to be set up. It has a panel in "Scene Properties" in Blender, the tab in the bottom right (By default) panel with a droplet and some other crap.
-- Not setting up BST can be a large source of beginner pain!
-- Turn on Word Wrap to read this file more easily.

-- Step 1: Preparation
-- The first thing you need to do is to get your model. Usually this will be in another game or addon or something.
-- If it's a Source game, Crowbar can extract them.
-- If it's a Gmod addon, Crowbar can extract them too.
-- After you have this model, you need to decompile it. This can be done with Crowbar, once it's set up. You don't need to touch any of the checkboxes, though "Folder For Each Model" can help.
-- Now, all you have to do is enable Blender Source Tools (They have a tutorial on how to do it) and import the .SMD model.

-- Step 2: The Model Itself
-- Fair warning, I'm not going to explain hotkeys here; if you need to learn how to do something, look it up. Yes, this will add time to the process, but trust me, having this tutorial is going to make life 400% easier for you.
-- Once you import a model, it'll usually have a skeleton, probably with some hands. You could work on the back of that, but I find it easier to just delete it all and start again from scratch.
-- Select the skeleton and delete it.
-- Then, select the model, go into the vertex group tab (The green triangle) and delete all vertex groups. There's a "Delete All" function in the dropdown to the right of all the vertex groups.
-- Next, you'll have to get a new skeleton. I recommend just taking one from one of my guns, because they're all setup about the same, and they're all setup *correctly* most importantly. Technically you don't need to do this, but they're all known values and... look, it's just easier this way.
-- Use your number pad to go into orthogonal view to line up the bones to where they need to be. This only really matters for the muzzle, eject position, slide bone, charging handle bone and scope bone where applicable.
-- The names of the bones don't matter, you can change them all later, though explanatory names are helpful.
-- All bones should point FORWARD.
-- Then, parent the gun to the skeleton with empty groups.
-- The bones will show up in the vertex group tab as vertex groups. In your gun, simply assign the appropriate vertex groups to all moving geometry. Generally this will just be the bullet, slide, and fire selector, though some guns will have a charging handle as well.
-- Use Select Linked to do this more easily.
-- After this is done, you need to make an idle animation. Select your skeleton.
-- Enter "Pose Mode".
-- Select all bones.
-- Hit "I" and make a full character keyframe.
-- in the outliner, go into the skeleton and select the animation. Rename it to "idle".

-- OPTIONAL Step 2.1: Adding a scope
-- Adding a scope is actually dead easy. All you need to do is to select your lens surface, then assign it to another material.
-- Then, just make sure it's UV unwrapped properly. The scope "output" is drawn to a 256x256 square, so just make sure you keep that in mind. Usually, U -> "Project From View" produces decent results, though it may not be oriented properly.
-- To find out whether it's oriented properly I usually get a material with a white square in the bottom left corner, because then if in the 3D view I see that it isn't in the bottom left corner of the scope, I know to flip the UV.

-- OPTIONAL Step 2.2: Adding a holographic sight
-- This is actually surprisingly a little harder than a scope, but still not difficult.
-- First, get the surface you want your holographic sight to be drawn "on". Think of this like the glass.
-- Split off this geometry. This should be a seperate model.
-- Make sure it's on the same skeleton (Armature) as the gun.

-- Step 3: Compile
-- The main focus of this step is in making a .QC file that Crowbar can compile for you into a working model Gmod can load.
-- Personally I recommend just using one from my guns, and editing it.
-- The main things you need to set are:
-- Model name/path.
-- Model .SMD source. Obviously.
-- CDMaterials. These are the directories the model will search for materials in. Copy these from the .QC you got from decompiling.
-- Attachments. These are crucial for the muzzle, eject pos, scope, and holosight, where applicable. **ATTACHMENT NAMES ARE NOT CODE NEGOTIABLE; USE "SCOPE", "HOLOSIGHT", ETC.**
-- Idle animation. This just needs to be one frame, because this is how Source interprets the "Base" form of the model.
-- After you write your .QC file (Easier than it sounds, really) you can have Crowbar compile it.
-- Beware! Not all Source games' compilers are the same. I recommend just using Gmod's.
-- Tick "No P4" if it isn't ticked for you. P4 is some professional ♥♥♥♥♥♥♥♥. You don't have it. Just tick the box.
-- Direct the output straight to an addon's folder under /addons. This is because it'll have the models/weapons/whatever.mdl path already set. You could put it into a different folder or whatever, but why would you?

-- Step 4: Weapon Definition
-- This is the part where you make the gun work.
-- You could spend anywhere from a minute to a day on this part.
-- Don't worry! No actual coding knowledge is required!
-- You can just copy an existing gun and modify it. Every parameter that can be defined can be read about here.
-- The rest of this "tutorial" is underneath. I suggest you go through the whole thing at least once.
-- Important! SWEP.BoneIndices can be set near-automatically with the console command "arcticvr_printvmbones". You may need to edit the names if they don't match what ArcVR wants.
-- To define a magazine, see lua/arcticvr/magazines.
-- To define an ArcVR bullet case/bullet, see lua/autorun/cl_arcticvr_cases.lua.
-- Happy hunting! If you're still confused you can pop by the Discord server; a link is on the ArcVR workshop page.

-- Step 5: (Added in Attachment Update)
-- Okay, so: Attachments.
-- Reference arcticvr/attachments/default.lua for a list of all the possible parameters
-- Reference also SWEP.Attachments in this file
-- Attachments are bonemerged
< >
Showing 1-3 of 3 comments
SophieBaybey Jan 14, 2021 @ 7:16pm 
Be sure to check the shared.lua file yourself, as underneath this tutorial is more information on the lua code for the addon. This should be enough to getcha started though!
simon Jan 15, 2021 @ 5:32am 
Oh,thanks.
Abraham Drinkin Jul 6, 2022 @ 6:29am 
Man I have scoured the internet for something like this for the past 3 days. I managed to get the black mesa crossbow into gmod but it's totally broken. Thank you for this!
< >
Showing 1-3 of 3 comments
Per page: 1530 50