AttachableSimpleFirearm

Updated a year ago

AttachableSimpleFirearm

This documentation provides an explanation of the code for the AttachableSimpleFirearm class. This is used for the 3Gl so im not sure if it useful beyond that.

Class Structure

The AttachableSimpleFirearm class is a subclass of AttachableFirearm within the AndrewFTW namespace.

Public Fields

The class has the following public fields:

  • Chamber (FVRFireArmChamber): The firearm chamber associated with the simple firearm.

Trigger Config

The class has the following trigger configuration fields:

  • Trigger (Transform): The transform representing the trigger.
  • TriggerFiringThreshold (float): The threshold value for firing the firearm.
  • TriggerResetThreshold (float): The threshold value for triggering the reset event.
  • Trigger_ForwardValue (float): The forward value of the trigger.
  • Trigger_RearwardValue (float): The rearward value of the trigger.
  • TriggerAxis (FVRPhysicalObject.Axis): The axis used for trigger interpolation.
  • TriggerInterpStyle (FVRPhysicalObject.InterpStyle): The interpolation style used for trigger animation.

Fore Slide Stuff

The class has the following fields related to the fore slide:

  • MoveableComponent (MovableObjectPart): The moveable component associated with the fore slide.

AudioSets

The class has the following audio-related fields:

  • AudioSets (FVRFirearmAudioSet[]): An array of audio sets for different round capacities.

Debug

The class has a debugging field:

  • isDebug (bool): A flag to enable/disable debug logging.

Public Methods

The class has the following public methods:

  • Awake(): Overrides the base class method to handle the awake event.
  • Update(): Overrides the base class method to handle the update event and update moving parts.
  • ProcessInput(FVRViveHand hand, bool fromInterface, FVRInteractiveObject obj): Overrides the base class method to process input each frame and handle trigger actions.
  • Fire(bool firedFromInterface): Fires the firearm and performs related actions such as playing audio and applying recoil.
  • UpdateComponents(): Updates the firearm components each frame, including animating the trigger.
  • LoadChamber(): Loads a round into the firearm chamber from the magazine if the chamber is empty and rounds are available.
  • SwapAudioSet(): Swaps the audio set based on the current number of rounds in the magazine.