top of page

Day 28: Back to weapon modelling

My plan for the day:

I wanted to import a sword model from online sources that I could then script to make it function as a custom weapon. What I accomplished: Once I found the sword model I wanted, I imported it as an .fbx file and made it a prefab in Unity. Obviously I could just adjust the swords positioning and make it a child of the player to seemingly make a weapon, but that would only delay what I would have to do later on, and cause more problems. A player inventory is crucial in any game, as is a weapons manager script. By getting these critical steps out of the way early on, I can build a foundation to then later work on other items that could be in the game. The first script I started working on was the function to handle loading the weapon model in our hands. By simply placing it near the player's hands and pretending the character was holding it, there would be lots of problems with the animations for attacking and sprinting. Once the scripting was done, it was time to adjust the weapon model in the hands of the player, since it was rotated the wrong way right now. To do so, I simply opened up the prefab of the right arm first, and in play mode, made the rotation to the way I wanted it to be. I then copied the component's transform and rotation and plugged that into the prefab, and repeated the process for the left arm. Now, both arms had swords that would function and move along naturally to the player locomotion animations.


_____________________________________________________________________________________________________



Image Source: The code for the weapon loading

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page