Custom Weapon States in UFPS

Sharing is caring:

What are Weapon States?

In this UFPS video we’ll be continuing with our custom weapon by configuring custom states. We’ll be creating tweaks for the two reload states, the run state and the zoom state. Building off the original pistol settings we’ll adjust our weapon settings and show you how to save the tweaks into a text file. States are just a list of settings to use whenever a certain state is being called.

The pistol has two reload states,so we’ll be using the same configuration for our M4 rifle. The first state will rotate the rifle to simulate the magazine being released then subsequently added in. Since the magazine portion of the rifle is off screen this will just add to the illusion that this state is acting as a reload animation.

The second state will involve the rifle being rotated with the barrel pointing upward to simulate the charge handle being pulled backward. Both of these states will work back to back to create a reload state.

We’ll then take a look at how to adjust the rifle for the zoom settings. For this we’ll once again be in the game mode and move the rifle up close to the camera and in the center, lining up the center of the screen with the iron sights of the rifle.

For this we’ll zero out the rotation settings for the weapon and turn off the “shake speed” to reduce any movement while zoomed in.

Lastly we’ll cover the “run state” which is the state being called whenever the shift button is held down. For this state I decided to have the rifle draped across the chest similar to the sprint movements in Battlefield 4.

So we’ll rotate the weapon to be perpendicular to our character. With this state it’ll seamlessly switch between the running motions and the default state with the rifle pointing forward. After this you’ll be able to adjust any other states in your game. States for any other script will be similarly adjusted.

 

Software Used

UFPS by VisionPunk

States Text Files

*State settings may differ slightly from video

reloadM4.txt

///////////////////////////////////////////////////////////
// Component Preset Script
///////////////////////////////////////////////////////////

ComponentType vp_FPWeapon
RotationOffset -3.4 -2.64 -51

reload2M4.txt

///////////////////////////////////////////////////////////
// Component Preset Script
///////////////////////////////////////////////////////////

ComponentType vp_FPWeapon
PositionOffset 0.04 -0.42 0.35
RotationOffset -60 -5 0

zoomM4.txt

///////////////////////////////////////////////////////////
// Component Preset Script
///////////////////////////////////////////////////////////

ComponentType vp_FPWeapon
PositionOffset 0 -0.3 -0.16
RotationOffset 0 0 0 
ShakeSpeed 0.0

zoomShooterM4.txt

///////////////////////////////////////////////////////////
// Component Preset Script
///////////////////////////////////////////////////////////

ComponentType vp_FPWeaponShooter
MuzzleFlashPosition 0 -0.11 1.08
ShellEjectPosition 0.14 -0.2 0.86

runM4.txt

///////////////////////////////////////////////////////////
// Component Preset Script
///////////////////////////////////////////////////////////

ComponentType vp_FPWeapon
PositionOffset 0.4 -0.33 -0.04
RotationOffset 0.6 -53.64 23.48

Jonathan Gonzalez

I love all things in game development and want to contribute by teaching others how to create games. I'm always looking to help others create awesome digital worlds. I've been a hardcore gamer since I was a kid and now it's my turn to create awesome digital experiences.

More Posts - Website

Follow Me:
TwitterYouTube

Speak Your Mind

*