3D Survival FPS Game

Continuing from the preview article we will now complete the reloading animation and also learn how to trigger the reloading animation via scripting.

Animating the Pistol Components:

To get the pistol to reload more realistically we are going to have the ammo clip drop from the chamber and also have the top roofing of the gun pulled all the way back. When the dropped ammo clip is returned back simulating a brand new clip with the hand, we will have two things happen. The top roof pulls forward and there will be a slight movement like a jolt upward simulating pressure.

To start we are going to add several components within the Animation sidebar. The Clip Position and Rotation, the Left Hand Target position along with the Top section of the gun barrel.

Similar to how we started animating movement with the gun movement, we are going to do the same thing, hit the play button and then record within the Animation. That way you can see your actions in real time, and can adjust accordingly.

Start with the top roof pulled back a bit to replicate an empty chamber.

When the gun is fully pulled back, we are going to do animate two things, first is to get access the clip within our gun and animate a dropped motion. Keep and eye on the actual “Game” View, as long as the clip is outside of the camera view then that is all we need.

At the same time, we are going to access the Left hand position and pull back to mimic the left hand retrieving a brand new clip. We want this hand movement to start before the clip falls out.

Finally after a few seconds of idle, we are play everything within reverse, the clip and the hand should return back to normal together so we have to maybe adjust the timing on both actions.

Then we are going to move the roof of the gun barrel to slide back to normal position, along with having the overall pistol position have a jolt of movement, all before returning back to the normal position.

Scripting the Reload:

Within our Pistol script in the Update method we are going to add another IF condition for the KeyCode R when pressed down. When the key is pressed we are going to trigger the animation Condition “Reload”.

Now whenever the button is pressed, you will see the reloading action happen.

--

--

--

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.