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
Name | Description | |
---|---|---|
UxrFirearmWeapon |
Methods
Name | Description | |
---|---|---|
GetAmmoCapacity | Gets the attached magazine maximum capacity. | |
GetAmmoLeft | Gets the ammo left in the attached magazine. | |
HasMagAttached | Checks whether there is a magazine attached that fires shots using the given trigger. It may or may not have ammo. | |
IsLoaded | Checks whether a trigger is in a loaded state, meaning it is ready to shoot if pressed and there is any ammo left. | |
OnDisable | Unsubscribes from events. (Overrides UxrGrabbableObjectComponent<T>.OnDisable().) | |
OnEnable | Subscribes to events. (Overrides UxrGrabbableObjectComponent<T>.OnEnable().) | |
OnProjectileShot | Event trigger for ProjectileShot. | |
Reload | Sets the given weapon trigger loaded state so that it is ready to shoot if there is ammo left. | |
SetAmmoLeft | Sets the ammo left in the attached magazine. | |
SetTriggerPressed | Sets the trigger pressed value. | |
Start | Initializes the component. (Overrides UxrComponent.Start().) | |
TryToShootRound | Tries to shoot a round using the given trigger. |
Events
Name | Description | |
---|---|---|
ProjectileShot | Event called right after the weapon shot a projectile using the given trigger index. |
Fields
Name | Description | |
---|---|---|
_recoilAxes |
Extension Methods
Name | Description | |
---|---|---|
CheckSetEnabled | Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.) | |
GetOrAddComponent<T> | Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.) | |
GetPathUnderScene | Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.) | |
GetSceneUid | Gets an unique identifier string for the given component. (Defined by ComponentExt.) | |
GetUniqueScenePath | 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.) | |
LoopCoroutine | Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.) | |
SafeGetComponentInParent<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.) | |
ShowInInspector(Boolean) | Overloaded. Controls whether to show the current object in the inspector. (Defined by ObjectExt.) | |
ShowInInspector(Boolean, Boolean) | Overloaded. Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.) | |
ThrowIfNull | Throws an exception if the object is null. (Defined by ObjectExt.) |