This series of tutorials is designed for those who want to learn how to create their own weapons for video games, be it AAA First Person Shooter (FPS), Survival Game or Third Person Shooter (TPS)... Weapon modeling is a very simple matter, but it takes a lot of time, since initially we have to create High-Poly model, after that we have to retopologize, thereby optimizing the model for games, bake Normal Map with High-Poly, impose high-quality Physically Based Rendering(PBR) textures and rigging of 3D models for subsequent animation. The series of lessons will be divided into 3 parts: 1. Modeling a pistol, 2. Creating materials and animations for Glock, 3. Importing the model into Unity3D and creating a firing script.

To create this model, we will take a free and very powerful software. Blender3D... The latest version of Blender at the time of this writing is 2.78. You can download it from the official website. You can use any other software: 3DS Max, Maya and even domestic Compass-3D, the difference will be only in the program interface. To create textures, we will use everyone's favorite Photoshop but will also work Gimp.

To create Game-ready glock, we need to stick to this plan:
1. Find blueprints and some pistol references
2. Start Modeling High-Poly
3. Optimize 3D model for games
4. Create PBR textures
5. Import Glock into Unity

Glock Pistol Blueprints

Drawings are required to create most models. We found a nice picture of a pistol Glock 19 front, back and sides. The photos don't match exactly, but such errors shouldn't interfere with the process. Still, it is better to use accurate drawings, for example from this or this site. So, to add an image to the background, you need to: press the key N, in the menu that opens, find the tab Background Images> Add Image and select the file you want. To see the image, you need to switch to orthogonal mode by pressing 5 on Numpad... There is an important characteristic below - Opacity(Transparency). Add a few more references in the same way, but temporarily disable them in this tab. If you do not like this method, then you can enable the addon Images As Planes at User Preferences> Add-ons.

Drawings cannot show cuts or small parts on the gun. Here references from Google... Search for as many pictures of the Glock from different angles as possible.

High-Poly Weapon Simulation

While creating High-Poly model there is no need to save polygons, use as much as you see fit. Do not spare polygons for all sorts of small details and cuts. For convenience, you can use Hotkeys(hotkeys) that will greatly simplify your life and save you a lot of time. All useful Blender keyboard shortcuts are written in this article:. We only need a few of them: E- extrusion, G- moving, S- scaling, Ctrl + B- chamfer, Z- transition to the mode Wireframe,X- deletion, A- selection of all elements, if you press A in edit mode, then all points / edges / planes will be selected, H- hide the object.

High-Poly Glock Retopology

At this stage, we need to optimize our 3D model for video games. AAA weapons should now have up 20.000 Tris, if it's an automaton, up 10.000 Tris if it's a gun. These are approximate values ​​and are different for each project. BlenderMania has released a very good tutorial on how to retopologize a high-poly object onto a Low-Poly 3D model.

In this tutorial, the author explains how to use Blender3D and MeshLab to create a quick retopology with a minimum of effort and time. In our case, there is no need to use MeshLab, we will create Low-Poly model from scratch, as shown in this video tutorial:

Our model should be divided into 4 parts: the bolt, the trigger, the magazine and the main part. The magazine, as well as the bolt and trigger, should consist of a minimum number of polygons, because most of the polygons will go to the base of the pistol.

Create UV mapping low poly model. To bake Normal Map you need to choose our High-Poly model, then choose our Low-Poly, go to the tab Render... You need to make sure that we have selected Blender render... Find in this tab Bake> Bake Mode = Normals, Normal Space = Tangent, Selected to Active. We press Bake... After baking, the normal maps need to be saved by pressing F3... Go to the tab Materials, create a new material, in the tab Textures select our normal map, in Influence disconnect Color, Geometry> Normal. V Mapping Coordinates should be switched from Generated on UV... Add light to the scene and see the result.

In the next tutorial we will create textures and animations for our pistol.

Fashion are add-ons developed by ordinary players that add new content to Minecraft: items, vehicles, biomes and much more. Add-ons for new weapons are among the most popular among players around the world, as the firearm significantly dilutes the gameplay of the game.

There are a lot of modifications that add firearms and armor to Minecraft on your computer, so you can easily find what you like. Hundreds of different models of popular guns from real life, well-known barrels from CS and CS: GO. Do you like tough gunfights? Take a machine gun and release a couple of clips at the enemy. More like silent hidden killers? We quickly grab a sniper rifle with a telescopic sight and take out the enemy with one hit.

What types of weapons do mods add?

As mentioned above, there are a huge number of models. Below I will try to divide all of them into some categories and give several examples each.

  • Assault Rifles (CS Weapons): Kalash 47, M4A1, Famas F1, Galil;
  • Pistols and revolvers: Colt, Deagle, TT;
  • Shotguns: Mossberg, Remington, double-barreled guns;
  • Sniper rifles: AWP, Mosin rifle, Remington 700 LTR;
  • Exploding weapon: Grenades, mines, bazookas.

This is just a small part of the weapons from the Minecraft mods that you have to get acquainted with.

Firearms on site

On our site you can download the coolest and newest weapon mods for free. Each mod will have a detailed description, screenshots and direct download links.

First, go to the addons folder - D: \ Games \ Red Garry "s Mod \ Game \ garrysmod \ addons
Create a new folder, rename its name to our own, for example SWEP.

Next, we create a text file addon.txt.
We enter into it:
"AddonInfo"
{
"name" "Swep" // Replace Swep with your addon name.
"author_name" "Author" // Replace Author with your nickname.
"author_url" "Url" // Here you can write a page of your site. Example -
"info" "Swep" // Enter information about your weapon here.
}
In principle, you can leave everything as it is.
Next, create a lua folder.

How and what?

Now you can create weapons.
Open our .lua file, and enter this code at the very beginning:

SWEP.PrintName = "Chair Thrower" // This is the name of our weapon.
SWEP.Author = "I am athor" // Here you can specify the author's nickname. Enter your nickname in quotes.
SWEP.Instructions = "Left mouse to fire a chair!" // This is the addon instruction.

SWEP.Spawnable = true // Here you can enter permission for a simple player, if there = true as in our case, then the player is allowed to use this weapon, if = false then the player is not allowed to use it.
SWEP.AdminOnly = true // The same as in the case above, only here permission / prohibition of weapons is given to the admin.

SWEP.Primary.ClipSize = -1 // This function is responsible for the number of cartridges in the magazine, if the value = -1, as in our case, then the cartridges in the magazine are infinite.
SWEP.Primary.DefaultClip = -1 // Amount of ammo when receiving a weapon.
SWEP.Primary.Automatic = true // The type of weapon is automatic or rifle. In our case = true is a machine gun, in case = false is a rifle.
SWEP.Primary.Ammo = "none" // Cartridge type.

SWEP.Secondary.ClipSize = -1 // Here everything is the same as in the top
// functions.
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"


SWEP.AutoSwitchTo = false // Auto switch weapons.
SWEP.AutoSwitchFrom = false

SWEP.Slot = 1 // Weapon slot, if = 1, then our weapon will be in the first slot next to the mount.
SWEP.SlotPos = 2 // Position of the weapon in the slot.
SWEP.DrawAmmo = false // Hiding the number of cartridges in the hud, if = false, then the cartridges are hidden, if = true, then the cartridges remain.
SWEP.DrawCrosshair = true // Hiding the crosshair.

SWEP.ViewModel = "models / weapons / v_pistol.mdl" // IMPORTANT: Here we write the path to the weapon. This is the model that the player will hold.
SWEP.WorldModel = "models / weapons / w_pistol.mdl" // IMPORTANT: Here we write the path to the weapon. This is a model that will not be matched.

local ShootSound = Sound ("Metal.SawbladeStick") // Sound when fired.

Now let's move on to the main functions.

function SWEP: PrimaryAttack () // IMPORTANT: This function is responsible for the properties of the shot from the left mouse button.

self.Weapon: SetNextPrimaryFire (CurTime () + 0.5) // This indicates when the next shot will fire. 0.5 you can change to your liking.

self: ThrowChair ("models / props / cs_office / Chair_office.mdl") // Chair attack function. If it doesn't work for you, install Counter-Strike Source content or rename the model to models / props_c17 / FurnitureChair001a.mdl

function SWEP: SecondaryAttack () // The function is responsible for shooting from the right mouse button.

self: ThrowChair ("models / props_c17 / FurnitureChair001a.mdl") // Function to attack with chairs.

function SWEP: ThrowChair (model_file) // This is the chair function itself.

self: EmitSound (ShootSound) // Play weapon sound.

if (CLIENT) then return end

local ent = ents.Create ("prop_physics")

if (! IsValid (ent)) then return end

ent: SetModel (model_file) // Path to the model, in this case we do not specify anything since the models have already been specified in the shot functions.

ent: SetPos (self.Owner: EyePos () + (self.Owner: GetAimVector () * 16)) // Indicates where the model will appear.
ent: SetAngles (self.Owner: EyeAngles ())
ent: Spawn () // Spawn Our Weapon

local phys = ent: GetPhysicsObject ()
if (! IsValid (phys)) then ent: Remove () return end

local velocity = self.Owner: GetAimVector ()
velocity = velocity * 100 // The force of the shot, you can specify 7000 to make the chairs fly at bullet speed.
velocity = velocity + (VectorRand () * 10)
phys: ApplyForceCenter (velocity)

cleanup.Add (self.Owner, "props", ent) // The remove chair function, as you can see the code categorizes it as props.

undo.Create ("Thrown_Chair") // Main function to remove the chair when z is pressed.
undo.AddEntity (ent)
undo.SetPlayer (self.Owner)
undo.Finish ()
end

// That's all, your weapon is ready, you can change the properties to your liking.
// Search in the Other weapons category.

Create a lua file, for example: weapon_scripted_357.lua in 357 Scripted SWEP / lua / weapons folder.

Now let's write the code itself accordingly.
Where there are quotes, you need to specify the names in quotes.

SWEP.Author = "Hds46" // Nickname of the author of the swap. You must specify it in quotes.
SWEP.PrintName = "357 Magnum" // The name of the sweep that will be displayed.
SWEP.Contact = "Your site or mail" // Contact information for which you will be writing about bugs and suggestions.
SWEP.Purpose = "357 Scripted Weapon" // Brief information about the weapon.
SWEP.Instructions = "Shoot" // Instructions on how to use our swep.
SWEP.Category = "My Weapons" // Category where the weapon will be.
SWEP.Spawnable = true // If false then the weapon cannot be spawned, if true then it is possible.
SWEP.AdminOnly = false // If false then everyone can use the weapon, if true then only admins.

SWEP.ViewModelFOV = 64 // Here you can specify the zoom in / out of the weapon model from the player's screen.
SWEP.AutoSwitchTo = true // If true then the player automatically switches to this weapon (if picks it up), if false then no.
SWEP.AutoSwitchFrom = false // The same, but with different swaps.
SWEP.Slot = 1 // Weapon position in Hud "e.
SWEP.SlotPos = 3 // Position of the weapon in Hud (at the bottom)
SWEP.Weight = 5 // Weight of the weapon.
SWEP.DrawCrosshair = true // If true, the crosshair is shown, if false, then no.
SWEP.DrawAmmo = true // If true, then the indicator of the player's magazine is shown, if false, then no.

SWEP.ViewModel = "models / weapons / c_357.mdl" // First person model directory.
SWEP.WorldModel = "models / weapons / w_357.mdl" // Third person model directory.

SWEP.Primary.Sound = "Weapon_357.Single" // The sound of a shot. You can specify the directory, or you can specify the sounds registered in the script folder.
SWEP.Primary.Tracer = "Tracer" // Bullet trace name.
SWEP.Primary.TakeAmmo = 1 // Amount of ammo that is consumed with each shot
SWEP.Primary.Spread = 0.01 // Accuracy of the weapon, so that the weapon shoots exactly like an elephant-gun from a cs, write 0 or 0.01
SWEP.Primary.Delay = 1 // Rate of fire weapon (you can make a machine gun or machine gun)
SWEP.Primary.Recoil_pitch = -8 // Value required to recoil the weapon (Recoil up)
SWEP.Primary.Recoil_yaw_min = -2 // Minimum value for math.Rand code
SWEP.Primary.Recoil_yaw_max = 2 // Maximum value for the math.Rand code, it will choose a random decimal number in the range from -2 to 2. The value needed to recoil the weapon (Recoil right and left)
SWEP.Primary.Recoil_roll = 0 // The value required to recoil the weapon (Front recoil)
SWEP.Primary.Damage = 65 // Weapon damage.
SWEP.Primary.NumberofShots = 1 // Number of bullets fired on each shot (Shotgun)
SWEP.Primary.ClipSize = 6 // The maximum number of bullets in the store.
SWEP.Primary.DefaultClip = 6 // Maximum number of bullets in the magazine when picking up weapons.
SWEP.Primary.Automatic = true // If true then you can hold down the mouse button and shoot without stopping, if false then you need to press the attack button again.
SWEP.Primary.Ammo = "357" // Name of the used ammunition.
SWEP.HoldType = "revolver" // The type of animations the player is playing.

SWEP.UseHands = true // If true then c_models use custom hands, if false then no.

SWEP.Base = "weapon_base" // Base for weapons. Needed to borrow a couple of necessary features.
// Our weapon doesn't have alternate shot functions, so we don't need Secodary values.
SWEP.Secondary.Delay = 0.1
SWEP.Secondary.Recoil = 0
SWEP.Secondary.Damage = 0
SWEP.Secondary.NumberofShots = 1
SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"

function SWEP: Initialize () // Initialize the weapon where you want to pre-track sounds and specify the type of animations.
util.PrecacheSound (self.Primary.Sound)
self: SetWeaponHoldType (self.HoldType)
end

function SWEP: Reload () // Function when reloading
if (self: GetNextPrimaryFire ()> CurTime ()) then return end // This is necessary so that it does not reload during the shot.
if (self.Weapon: Clip1 ()< self.Primary.ClipSize && self.Owner:GetAmmoCount(self.Primary.Ammo) >0) then // Check for ammo. If the weapon has less ammo than usual and the player has ammo, then the code is next.
self: SetNextPrimaryFire (CurTime () + 3) // Time of the next shot, because the player will not shoot directly during reloading.
self: DefaultReload (ACT_VM_RELOAD) // Reload animation (first person)
self.Owner: SetAnimation (PLAYER_RELOAD) // Animation of player reloading (from third person)
end
end

function SWEP: PrimaryAttack () // Function of the left mouse button shot.
if (! self: CanPrimaryAttack ()) then return end // If there is no ammo, the weapon cannot fire.
local tr = self.Owner: GetEyeTrace () // Direction of the player's sight.
local bullet = () // Bullet structure, values ​​will be used from the values ​​described above, only instead of SWEP - self.
bullet.Num = self.Primary.NumberofShots
bullet.Src = self.Owner: GetShootPos ()
bullet.Dir = self.Owner: GetAimVector ()
bullet.Spread = Vector (self.Primary.Spread * 0.1, self.Primary.Spread * 0.1, 0)
bullet.Tracer = self.Primary.Tracer
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo

self: TakePrimaryAmmo (self.Primary.TakeAmmo)

self.Weapon: MuzzleFlash () // Flash the shot.
self.Owner: FireBullets (bullet) // This code takes all values ​​from bullet (above) and allows the player to shoot bullets.
self: EmitSound (Sound (self.Primary.Sound)) // Plays the sound of the shot.
self.Owner: ViewPunch (Angle (self.Primary.Recoil_pitch, math.Rand (self.Primary.Recoil_yaw_min, self.Primary.Rec
oil_yaw_max), self.Primary.Recoil_roll)) // Return, takes the values ​​I described above.
self.Weapon: SendWeaponAnim (ACT_VM_PRIMARYATTACK) // Plays a shot animation (first person)
self.Owner: SetAnimation (PLAYER_ATTACK1) // Plays animation of the shot (third person)
self: SetNextPrimaryFire (CurTime () + self.Primary.Delay) // Time of the next shot.
end

function SWEP: SecondaryAttack () // Function to fire the right mouse button. (We won't need it)
end

function SWEP: Deploy () // Function when picking up weapons.
self: SetNextPrimaryFire (CurTime () + self.Primary.Delay) // Time of the next shot, the player will not shoot until he takes the weapon out of the holster.
self.Weapon: SendWeaponAnim (ACT_VM_DRAW) // Animation of picking up weapons (from the first person)
return true // If true then allows to raise the weapon, if false then not.
end

function SWEP: Holster () // Function when holstering the weapon.
return true // If true then allows holstering the weapon, if false then no.
end

function SWEP: Think () // A function to play when the player is holding a weapon, every 0.01 milliseconds.
end

Heh i'm alive
FAQ:

Question: If the author is still alive, can you give a log of melee weapons? Very necessary
Answer: Unfortunately, I didn’t do x. weapons, and all this I did for the sake of leadership. So excuse me, I can give advice, write in the search engine "How to make simple weapon GMOD" there are many options, maybe x. the weapon will be.

Question: Listen, I've created a weapon, can I calmly pour it into the workshop?
Answer: Yes, this requires a special program:

Question: Question: is it possible to specify a custom sound "local ShootSound = Sound"?
Answer: Quite, point the way to the sound.

Question: Of course, normal leadership, but there is no other option? (Through some program, for example)
Answer: Unfortunately, there are no programs, there is an addon in the workshop, but there you can make too simple weapons.

Question: how to make a lua file?
Answer: Create a file, for example firstaddon.txt - right-click on the file - change it - and instead of .txt put .lua - save the changes and that's it :)

P.S Sorry for the delay, it was just not up to that :)

Good day, dear forum participants!
Today I will tell you how to implement your weapons for Counter Strike 1.6 and help you learn how to work with the FragMotion program.

What do you need today?


  • fragMOTION- Better not older than 1.1.
  • MilkShape 3D- at the very 1.7.6.
  • GUI StudioMDL- the last one.
  • Straight arms- from birth.

(Before going through the tutorial, take v_deagle.mdl and v_knife.mdl, and put them in separate folders for convenience).

Part one. Preparation for work.

1. First, open MilkShape 3D, then the Tools tab, and Kratisto's Half-Life MDL Decompiler v.1.x (x = version).
2. Press the browse button, the one to the right of the words MDL File ...

3. Open the usual v_deagle.mdl, which is in a specially prepared daddy.
4. Click OK, and wait for the process to complete.
5. Done! Open the folder and find the .smd, .bmp and .qc files in it.
6. Open our fragMOTION, click File -> Open ..., select ref_deonly.smd.
7. We will get the so-called "reference" deagle. Now we need to remove all bones except the mesh (model).

But before doing anything, open Edit -> Customize User Interface. If everything is default, click on the line and select Mouse Configurations.
You have the Default settings in front of you. By the way, it is very difficult to work on them.
Right click on MouseConfigurations tab -> New ... -> MouseConfig.
A new config will appear. We click on it with the left mouse button, and set up everything like mine.

Have you done everything? Click File -> Save Changes.

8. How do you remove these bones? Easily. Hold the right button and circle everything around the pistol. Press the Delete key. Ready.
9. It remains to prepare the gun for further use.
Click on Transform -> Transform Options ...
A window rolls out.

Uncheck the Scale box. We put a checkbox on Position, then the Apply button.
Our pistol is centered.
Now you need to turn it so that it lies flat in your hands ...
In hand? In hand?! What are we doing this?
This is what we do.

Part two. Roasting the bones.

10. Now you need to turn it so that it lies flat in your hands ...
Click on the Rotate checkbox, in the Y field, enter - 90.0000, and click Apply twice.
Erase the nine in the Y field, leave 0.0000. Now enter 90.0000 in the Z field.
Click on Apply three times.
11. Uncheck Rotate and tick Position. We leave everything as it is. Click Apply once.
Note: If suddenly the cannon flew where it is not necessary, press Apply until the pistol lies in the middle.

So, I didn’t tell one thing.
Click View -> Layout -> 4 corners. So it is very convenient to navigate in the future.
To fly in 3D, hold down the button on the mouse wheel. To rotate the camera, hold down Shift + Mouse3 (mouse wheel). I think you know how to bring it closer.

After all the operations described above, you should have something like this.

12. Click File -> Merge ..., open reference.smd from your decompiled knife. Not highlighting anything, just click OK.
Hands and a knife fall into the scene.

13. Now we need to destroy the remnants of the knife, and insert the pistol.
We do not touch the cannon, now we will deal with the knife.

14. Hold Shift + LMB (left mouse button), and draw a circle around the unnecessary knife.
Press the Delete key. Wow, the pieces are left!

15. Now in the Left, Top, Front views do the same, removing the last remnants of the knife.

16. Hurray! There is no knife, and now you can start baking the bones.
LMB two times ref_deonly.

Now LMB move the cannon to the blue dot, which is in place of the removed knife. Muzzle forward, respectively.

You should have something similar.

Note: Don't have textures on hand? Do not worry! It doesn't matter at all. I have the textures from the old exports.

17. Now select the RMB blue point, which is on our muzzle.
Note: The pistol must be necessarily highlighted and be red.

18. Now Bone -> Assign Selected Vertices to Bone.
Voila! The bone stuck to the cannon! To deselect, right-click on the scene, and the keyboard shortcut Ctrl + Shift + N.

Checking.

19. Let's see what happened. Click File -> Merge Animations ... and select for example draw.smd from knife. Not highlighting anything, click OK.
Now in the upper right corner there is a small Anim ... button, click. We get the following picture.

Select the draw animation and pull the slider below.

If everything worked out, then I am very happy for you!

Part three. Adding weapons to the game.

20. Create a separate daddy called Deagle Knife.

21. Click on the draw animation and click the Delete key. There is no animation, which means that we have in our hands the so-called reference.

21. Click File -> Export ..., save with the reference name, and below with Half-Life SMD Files (.smd) format.

Leave a dot on the Mesh.

22. Now, by the way, the easiest, but, let's say, very tedious.
Click File -> Merge Animations ... and select, for example, draw.smd.
Do not touch anything, click OK.
Then File -> Export ..., in spec. Daddy Deagle Knife, enter the name of the animation draw, format.smd.
Rolls out the window. Click on the Animation point and select draw below. OK,

Now you need to do the same with idle, midslash1, midslash2, slash1, slash2, stab, stab_miss.
Note: Don't touch the reference! We have already prepared it at the very beginning.

23. Open the daddy, check for the presence of such files.

24. If everything is in place, now we will get acquainted with a new program for us - GUI StudioMDL.

25. Transfer v_knife.qc from the folder with the decompiled knife to the Deagle Knife folder. Also, the knifeskin.bmp texture.
Note: Why? And in order not to bother changing the .qc code, let's leave the texture. It doesn't interfere.

26. From the folder with the decompiled deagle we get DE_slide1.bmp, DE_handle.bmp, DE_slide2_eagle.bmp, view_glove.bmp, view_skin.BMP, view_finger.bmp, and drop it into our Deagle Knife folder.

27. Move the Deagle Knife folder to the C: / directory so that GUI StudioMDL does not conflict with Cyrillic.

28. Open GUI StudioMDL, click File -> Load QC File.
Then we put a checkbox on Dump Hitboxes, and then, enthusiastically click on Compile.
If everything went well, v_knife.mdl will appear in the Deagle Knife folder.

Note throughout the lesson: You can insert not only the same deagle into your hand, insert a hacksaw, a screwdriver, a bucket, and anything else!

But now the third part has come to an end, and indeed the whole lesson. If anyone does not succeed, write, I will help as much as I can. Thank you for your attention, Valentine was with you.
In the next tutorial, I'll show you how to make your own firearms, and we'll seriously talk about attaching bones.

I also want to thank Michael, for his detailed explanations on this topic, and the entire portal Gcc for moral support.