Skip to content
Tomura edited this page Dec 22, 2021 · 3 revisions

General

A gun is a Gripable Static Mesh, with extended functionality to either implement logic for the gun itself or provides a default interface to additional components that make up a gun, such as a Charging Handle, Slide, Ejection Port, Magwells, etc. The default implementation of ATVRGunBase assumes contains only the bare minimum components, but will automatically detect other components on BeginPlay and assign events and variables to it. During this it has some assumptions:

  • There is only up to one Charging Handle
  • There is only up to one Ejection Port
  • There is only up to one Magazine Interface
  • There is only up to one Trigger (already defined)
  • There is only up to one Firing Component (already defined)
  • There is only up to one Skeletal Mesh for Movable parts with an animation blueprint of type UTVRAnimBlueprintGun. (It is possible to add other skeletal meshes, but you need to manually attach any logic to them)

Components

todo add links

Magazine Interface

These components have something to do with storing ammo and feeding them to the firing component. They all need to be children of UTVRMagazineInterface. These could be just a Mag Well (so the interface between the gun and the Magazine) or an Internal Magazine. Generally the default gun implementation assumes that there is only one Magazine Interface, a gun that has two magazine interfaces will only use the first one that was found during begin play, so if a different behavior is desired create you need to create a child that overrides this behavior.

The following components exist.

UTVRMagWellInterface

Component that a Magazine can be inserted to. It will provide an interface to this magazine and contains the logic for inserting or dropping the magazine.

UTVRInternalMagazine

Internal magazine that can be fed with ATVRCartridge (will only react to AllowedCartridges set in its properties). This is useful for weapons such as shotguns.

Charging Handle Interface

These components implement ITVRChargingHandleInterface and will provide functionality for the user to operate the action, or mainly the bolt itself. The following components exist:

UTVRChargingHandle

Reciprocating or non-reciprocating charging handle. It is only represented by a collision box that can be grabbed, thus any motion needs to be reflected by linking a Static Mesh to it, or by reflecting it in the animation blueprint of your weapon. At the moment it can only be pulled, but some locking logic is planned for G3-like weapons

UTVRPistolSlide

Reciprocating Slide. Mainly for Pistols. It is very similar to the charging handle, but is a Gripable Static Mesh Component.

UTVRPumpAction

Pump for a Pump Action Shotgun. Cannot really be gripped, but rather assumes it is the secondary grip area for the weapon. Can be unlocked using the Trigger of the gripping controller and then operated to charge the action. It in theory acts like a non-reciprocating charging handle, but would usually be used in weapons that do not cycle automatically.

Ejection Port

Handles Pooling and Spawning Cartridges from the Pool. Without this component Cartridges are still removed from the Firing Component in the logic, but it will not be represented visually.

UTVREjection Port

Trigger Component

Trigger logic, that can be configured, when it actually fires. At the moment it is not tied to any config file, but will be, so that a user can adjust it to their liking. It also offers the option to add a second firing stage.

Firing Component

Component that marks the location where gunfire originates from and handles all firing logic. Some properties will be taken from the loaded Cartridge like for example if the Cartridge fires Buckshot or a Slug, etc. Buckshot logic is optimized to only fire a limited amount of bucks (3 by default) in one frame, and will continue every frame until all pending bucks are fired. If a bullet logic is added, it will also Pool the bullet actors. This actor will be fed a cartridge (only reference to the cartridge class) and thus stores the loaded cartridge and takes it's information for firing.