Thursday 13 December 2018

Gun Model: From Maya to Unreal

After the test run of importing the barrel into Unreal, it was time to give importing my gun model ago. Most of the steps were similar to what I have explained in my previous post, the only extra step I carried out in Maya was to combine the separate components of the model into one mesh. This was done by selecting everything (right mouse button > select all) and then going to the Mesh tab > Combine. The Model was now ready for exporting to Unreal.



The next step was importing into Unreal. As I wanted the gun to be carried by the first person character, I would need to import the gun as a skeletal mesh. This is done by selecting the skeletal mesh check box in the import options. The skeleton should be set to none, this will force the engine to generate a new one for the model.


The gun model was now in the game, complete with textures, now to get it to actually work. Although I have set up a gun from scratch in my previously disbanded project, the easiest way to get it working quickly is to exchange the existing gun model for the newly imported one. Firstly, you need to find the first person character's skeleton, this is fact just a pair of arms. Once opened in the editor, you should see a list on the left that contains of all the bones that the skeleton consists of. Scroll down the list until you find one called 'GripPoint', this is not a bone but a socket on the skeleton where an another object can be attached. This one already exists as its where the default gun is held. You can use this one, but I duplicated it so I can easily revert to the default gun if needed. Now right click on the newly created socket and select 'Add Preview Asset'. A box with all your available assets will appear, just find your gun and it will appear in the right hand.


At this point the gun may look like its being held strange, or too big/small, this can be changed in a moment. First you need to change the skeleton to a more natural in game pose, such as an idle position. This done through the 'Preview Scene Set' on the right. Change the 'Preview Controller' to 'Use Specific Animation' and then select the idle animation. You should now see the skeleton in much more natural position. Select the socket you created again, now you can adjust the scale and position of the gun until you are happy with it.


After you are happy with how the gun looks, hit save and then close. Next, go to the first person character blueprint and then select the viewport tab. In the components list (top left), find the one called 'FP_Gun'. The details panel on the right will have the default gun as the skeletal mesh, change this to your gun. Don't worry if it looks strange again, or the size has changed, this will be fine in a moment. Now go to the construction script tab and you should see an 'AttachToComponent' node, change the socket name to the one you created on the skeleton, make sure it is spelt correctly! If you go back to the view port you should now see the gun being held as you intended.


The last step is adjust where the bullets are spawned from for your gun. You should notice there is a sphere component as a child of the 'FP_Gun', this is the location that bullets will be spawned at, so just line this up with the muzzle of your gun and now you should have a gun that fires projectiles. I also added a point light to my gun, as my Halo assault rifle has a flashlight mounted on the front.

No comments:

Post a Comment