Please or Register to create posts and topics.

Help with creating a custom viewmodel for the portal gun.

Hello all ! :)

I have seen a lot of custom portal gun models recently, like the one in the awesome "Portal Stories : Mel", or the one made by lamar11 for his mod "Portal 2 : Repercussions".

I would like to learn how to create a custom viewmodel for the portal gun.

I know how to model (I already made the model i want to use). The problem is that I have no idea on how to texture it, animate it, and use it as a viewmodel in the Portal 2 engine.
I know there are many tutorials on the internet, but I just don't know where to start...

It would be really great if you could guide me a little ^^
Thanks.

Making a puzzle is a puzzle in itself
My Workshop : >-Click Me-<
--> Reflection Gel Testing 4 <--
FireFusorf wrote:
The problem is that I have no idea on how to texture it, animate it, and use it as a viewmodel in the Portal 2 engine.

Well, about texturing or animating your custom portalgun, I'm afraid you'll have to learn it within your modelling program. There are many good tutorials about this for almost any modelling program, search for UV mapping and creating model animations.

I could try to help you out on how to implement your custom model in Portal2 though, but there are a couple of things you should be aware of before continuing:

- "Portal Stories: Mel" is a mod, and it even got greenlit so it's on Steam. This means that they can ship whatever custom portalgun model within the mod so that players can see it and use it.

- Unless you make a mod, you'll only manage to get a working portalgun for your screen :p, thus you won't be able to pack it in your BSP and make the rest to play with it in the workshop.

That said, this is how it works:

1. There's a script file called weapon_portalgun.txt located into your "portal 2/portal/scripts" folder. Take a look to it:

Code: Select all
// Portalgun

WeaponData
{
   // Weapon data is loaded by both the Game and Client DLLs.
   "printname"         "#Portal_Portalgun"
   "viewmodel"         "models/weapons/v_portalgun.mdl"
   "playermodel"         "models/weapons/w_portalgun.mdl"
   "anim_prefix"         "portalgun"
   "bucket"         "0"
   "bucket_position"      "2"

   "clip_size"         "1"
   "primary_ammo"         "None"
   "secondary_ammo"      "None"

   "weight"         "4"
   "item_flags"         "0"
   "damage"         "9"
   "autoswitchto"         "1"
 
   // Sounds for the weapon. There is a max of 16 sounds per category (i.e. max 16 "single_shot" sounds)
   SoundData
   {
      "single_shot"      "Weapon_Portalgun.fire_blue"
      "double_shot"      "Weapon_Portalgun.fire_red"

      // NPC SECTION
      "single_shot_npc"   "Weapon_Portalgun.fire_blue_npc"
      "double_shot_npc"   "Weapon_Portalgun.fire_red_npc"
   }

   // Weapon Sprite data is loaded by the Client DLL.
   TextureData
   {
      "weapon"
      {
            "font"      "WeaponIcons"
            "character"   "C"
      }
      "weapon_s"
      {   
            "font"      "WeaponIconsSelected"
            "character"   "C"
      }
      "ammo"
      {
            "font"      "WeaponIcons"
            "character"   "M"
      }
      "crosshair"
      {
            "font"      "Crosshairs"
            "character"   "."
      }
      "autoaim"
      {
            "file"      "sprites/crosshairs"
            "x"      "0"
            "y"      "48"
            "width"      "24"
            "height"   "24"
      }
   }
}

As you can see this file controls many things about the portalgun, the models the game uses for the viewmodel and for the worldmodel, its sounds, etc. You could just edit this file and change the paths to your own portalgun files. However, as you could imagine, if you ever use the "verify local files" tool from your game properties on the Steam library, this file will be replaced by the old one.

In order to make this slightly more permanent, you could use the "dlc3 method". You already fiddled with it, so I assume you know what I mean ;) Apart from the pak01_dir.VPK inside the dlc3 folder, create a "common/portal 2/portal2_dlc3/scripts/" folder and put your custom "weapon_portalgun.txt" file inside it... that should make the game to load your custom portalgun script file that is pointing to your custom model portalgun files.

Hehe.... and by the way... did you notice that last part of the script file where it says this:

Code: Select all
      "crosshair"
      {
            "font"      "Crosshairs"
            "character"   "."
      }
      "autoaim"
      {
            "file"      "sprites/crosshairs"
            "x"      "0"
            "y"      "48"
            "width"      "24"
            "height"   "24"
      }

:D I totally forgot that part was there. You can change the file that the game loads to make the crosshair in the HUD by editting the "file" path within the "autoaim" parameter putting the path to your custom crosshair file, as an alternate method to have your custom crosshairs ;)

ImageImageImageImageImageuseful tools and stuff here on TWP :thumbup:
[spoiler]ImageImageImageImageImage[/spoiler]

Thank you for your response :thumbup:

I looked up for tutorials, but I figured out that my model might not work, as it was made in Solidworks. I converted it into softimage mod tool sucessfully to texture it, but it was a real pain as solidworks creates a ton of useless polygons...

So i'm back at point zero now.
What program should I use for modeling/texturing/animating ? witch one is best suited for the source engine ?

Making a puzzle is a puzzle in itself
My Workshop : >-Click Me-<
--> Reflection Gel Testing 4 <--

Soft image xsi is the best choice IMO. I usually use milkshape since its extremely fast to model simple stuff and modify existing meshes, but its not exactly powerful in terms of the tools it has. Softimage has good animating, good controls, and a good modeling system..

My YouTube Channel: https://www.youtube.com/user/Camben24
Aperture Science: We do our science asbestos we can!