UxrFirearmWeapon Class

Type of weapon that shoots projectiles. A firearm has one or more UxrFirearmTrigger entries. Each trigger allows to shoot a different type of projectile, and determines properties such as the shot cycle, shot frequency, ammunition, recoil and grabbing. A UxrFirearmWeapon requires a UxrProjectileSource component that defines the projectiles being shot. If a firearm has more than one trigger (for instance, a rifle that shoots bullets and has a grenade launcher), the UxrProjectileSource will require the same amount of entries in ShotTypes.

Inheritance Hierarchy

System.Object
  Object
    Component
      Behaviour
        MonoBehaviour
          UltimateXR.Core.Components.UxrComponent
            UltimateXR.Core.Components.UxrComponent(UxrWeapon)
              UltimateXR.Core.Components.Composite.UxrGrabbableObjectComponent(UxrWeapon)
                UltimateXR.Mechanics.Weapons.UxrWeapon
                  UltimateXR.Mechanics.Weapons.UxrFirearmWeapon
Namespace: UltimateXR.Mechanics.Weapons
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0

Syntax

C#

[RequireComponent(typeof(UxrProjectileSource))]
public class UxrFirearmWeapon : UxrWeapon


The UxrFirearmWeapon type exposes the following members.

Constructors

NameDescription
Public methodUxrFirearmWeapon

Methods

NameDescription
Public methodGetAmmoCapacity Gets the attached magazine maximum capacity.
Public methodGetAmmoLeft Gets the ammo left in the attached magazine.
Public methodHasMagAttached Checks whether there is a magazine attached that fires shots using the given trigger. It may or may not have ammo.
Public methodIsLoaded Checks whether a trigger is in a loaded state, meaning it is ready to shoot if pressed and there is any ammo left.
Protected methodOnDisable Unsubscribes from events. (Overrides UxrGrabbableObjectComponent<T>.OnDisable().)
Protected methodOnEnable Subscribes to events. (Overrides UxrGrabbableObjectComponent<T>.OnEnable().)
Protected methodOnProjectileShot Event trigger for ProjectileShot.
Public methodReload Sets the given weapon trigger loaded state so that it is ready to shoot if there is ammo left.
Public methodSetAmmoLeft Sets the ammo left in the attached magazine.
Public methodSetTriggerPressed Sets the trigger pressed value.
Protected methodStart Initializes the component. (Overrides UxrComponent.Start().)
Public methodTryToShootRound Tries to shoot a round using the given trigger.

Events

NameDescription
Public eventProjectileShot Event called right after the weapon shot a projectile using the given trigger index.

Fields

NameDescription
Protected field_recoilAxes

Extension Methods

NameDescription
Public Extension MethodCheckSetEnabled Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.)
Public Extension MethodGetOrAddComponent<T> Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.)
Public Extension MethodGetPathUnderScene Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.)
Public Extension MethodGetSceneUid Gets an unique identifier string for the given component. (Defined by ComponentExt.)
Public Extension MethodGetUniqueScenePath Gets an unique path in the scene for the given component. It will include scene name, sibling and component indices to make it unique. (Defined by ComponentExt.)
Public Extension MethodLoopCoroutine Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.)
Public Extension MethodSafeGetComponentInParent<T> Gets the Component of a given type in the GameObject or any of its parents. It also works on prefabs, where regular GetComponentInParent(Type, Boolean) will not work: https://issuetracker.unity3d.com/issues/getcomponentinparent-is-returning-null-when-the-gameobject-is-a-prefab (Defined by ComponentExt.)
Public Extension MethodShowInInspector(Boolean)Overloaded.
Controls whether to show the current object in the inspector. (Defined by ObjectExt.)
Public Extension MethodShowInInspector(Boolean, Boolean)Overloaded.
Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.)
Public Extension MethodThrowIfNull Throws an exception if the object is null. (Defined by ObjectExt.)

See Also

Reference

UltimateXR.Mechanics.Weapons Namespace