VR Interaction Framework v2.0
Loading...
Searching...
No Matches
BNG.RaycastWeapon Class Reference

An example weapon script that can fire Raycasts or Projectile objects. More...

Inheritance diagram for BNG.RaycastWeapon:
BNG.GrabbableEvents

Public Member Functions

override void OnTrigger (float triggerValue)
 Amount of Trigger being held down on the grabbed items controller. Only fired if object is being held.
 
virtual void CheckReloadInput ()
 
virtual void UnlockSlide ()
 
virtual void EjectMagazine ()
 
virtual void Shoot ()
 
virtual void ApplyRecoil ()
 
virtual void OnRaycastHit (RaycastHit hit)
 
virtual void ApplyParticleFX (Vector3 position, Quaternion rotation, Collider attachTo)
 
virtual void OnAttachedAmmo ()
 Something attached ammo to us.
 
virtual void OnDetachedAmmo ()
 
virtual int GetBulletCount ()
 
virtual void RemoveBullet ()
 
virtual void Reload ()
 
virtual void OnWeaponCharged (bool allowCasingEject)
 
- Public Member Functions inherited from BNG.GrabbableEvents
virtual void OnGrab (Grabber grabber)
 Item has been grabbed by a Grabber.
 
virtual void OnRelease ()
 Has been dropped from the Grabber.
 
virtual void OnBecomesClosestGrabbable (ControllerHand touchingHand)
 Called if this is the closest grabbable but wasn't in the previous frame.
 
virtual void OnBecomesClosestGrabbable (Grabber touchingGrabber)
 Called if this is the closest grabbable but wasn't in the previous frame.
 
virtual void OnNoLongerClosestGrabbable (ControllerHand touchingHand)
 No longer closest grabbable. May need to disable highlight, ring, etc.
 
virtual void OnNoLongerClosestGrabbable (Grabber touchingGrabber)
 No longer closest grabbable. May need to disable highlight, ring, etc.
 
virtual void OnBecomesClosestRemoteGrabbable (ControllerHand touchingHand)
 Fires if this is the closest remote grabbable but wasn't in the previous frame.
 
virtual void OnBecomesClosestRemoteGrabbable (Grabber theGrabber)
 Fires if this is the closest remote grabbable but wasn't in the previous frame.
 
virtual void OnNoLongerClosestRemoteGrabbable (ControllerHand touchingHand)
 Fires if this was the closest remote grabbable last frame, but not this frame.
 
virtual void OnNoLongerClosestRemoteGrabbable (Grabber theGrabber)
 Fires if this was the closest remote grabbable last frame, but not this frame.
 
virtual void OnGrip (float gripValue)
 Amount of Grip (0-1). Only fired if object is being held.
 
virtual void OnTrigger (float triggerValue)
 Amount of Trigger being held down on the grabbed items controller. Only fired if object is being held.
 
virtual void OnTriggerDown ()
 Fires if trigger was pressed down on this controller this frame, but was not pressed last frame. Only fired if object is being held.
 
virtual void OnTriggerUp ()
 Fires if Trigger is not held down this frame.
 
virtual void OnButton1 ()
 Button 1 is being held down this frame but not last Oculus : Button 1 = "A" if held in Right controller."X" if held in Left Controller.
 
virtual void OnButton1Down ()
 Button 1 Pressed down this frame Oculus : Button 1 = "A" if held in Right controller."X" if held in Left Controller.
 
virtual void OnButton1Up ()
 Button 1 Released this frame Oculus : Button 1 = "A" if held in Right controller."X" if held in Left Controller.
 
virtual void OnButton2 ()
 Button 2 is being held down this frame but not last Oculus : Button 2 = "B" if held in Right controller."Y" if held in Left Controller.
 
virtual void OnButton2Down ()
 Button 2 Pressed down this frame Oculus : Button 2 = "B" if held in Right controller."Y" if held in Left Controller.
 
virtual void OnButton2Up ()
 Button 2 Released this frame Oculus : Button 2 = "B" if held in Right controller."Y" if held in Left Controller.
 
virtual void OnSnapZoneEnter ()
 Grabbable has been successfully inserted into a SnapZone.
 
virtual void OnSnapZoneExit ()
 Grabbable has been removed from a SnapZone.
 

Public Attributes

float MaxRange = 25f
 How far we can shoot in meters.
 
float Damage = 25f
 How much damage to apply to "Damageable" on contact.
 
FiringType FiringMethod = FiringType.Semi
 Semi requires user to press trigger repeatedly, Auto to hold down.
 
ReloadType ReloadMethod = ReloadType.InfiniteAmmo
 How does the user reload once the Clip is Empty.
 
float FiringRate = 0.2f
 Ex : 0.2 = 5 Shots per second.
 
float BulletImpactForce = 1000f
 
float InternalAmmo = 0
 Maximum amount of internal ammo this weapon can hold. Does not account for attached clips. For example, a shotgun has internal ammo.
 
float MaxInternalAmmo = 10
 Maximum amount of internal ammo this weapon can hold. Does not account for attached clips. For example, a shotgun has internal ammo.
 
bool AutoChamberRounds = true
 Set true to automatically chamber a new round on fire. False to require charging. Example : Bolt-Action Rifle does not auto chamber.

 
bool MustChamberRounds = false
 Does it matter if rounds are chambered or not. Does the user have to charge weapon as soon as ammo is inserted.
 
bool AlwaysFireProjectile = false
 
bool FireProjectileInSlowMo = true
 
float SlowMoRateOfFire = 0.3f
 
float ShotForce = 10f
 
float BulletCasingForce = 3f
 
Vector3 RecoilForce = Vector3.zero
 How much force to apply to the tip of the barrel.
 
float RecoilDuration = 0.3f
 
LayerMask ValidLayers
 
Transform TriggerTransform
 Transform of trigger to animate rotation of.
 
Transform SlideTransform
 Move this back on fire.
 
Transform MuzzlePointTransform
 Where our raycast or projectile will spawn from.
 
Transform EjectPointTransform
 Where to eject a bullet casing (optional)
 
Transform ChamberedBullet
 Transform of Chambered Bullet. Hide this when no bullet is chambered.
 
GameObject MuzzleFlashObject
 Make this active on fire. Randomize scale / rotation.
 
GameObject BulletCasingPrefab
 Eject this at EjectPointTransform (optional)
 
GameObject ProjectilePrefab
 If time is slowed this object will be instantiated instead of using a raycast.
 
GameObject HitFXPrefab
 Hit Effects spawned at point of impact.
 
AudioClip GunShotSound
 Play this sound on shoot.
 
float GunShotVolume = 0.75f
 
AudioClip EmptySound
 Play this sound if no ammo and user presses trigger.
 
float EmptySoundVolume = 1f
 
float SlideDistance = -0.028f
 How far back to move the slide on fire.
 
bool ForceSlideBackOnLastShot = true
 Should the slide be forced back if we shoot the last bullet.
 
float slideSpeed = 1
 
List< GrabbedControllerBindingEjectInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down }
 
List< GrabbedControllerBindingReleaseSlideInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button1Down }
 
List< GrabbedControllerBindingReloadInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down }
 
bool BulletInChamber = false
 Is there currently a bullet chambered and ready to be fired.
 
bool EmptyBulletInChamber = false
 Is there currently a bullet chambered and that must be ejected.
 
UnityEvent onShootEvent
 
UnityEvent onAttachedAmmoEvent
 
UnityEvent onDetachedAmmoEvent
 
UnityEvent onWeaponChargedEvent
 
FloatEvent onDealtDamageEvent
 
RaycastHitEvent onRaycastHitEvent
 

Protected Member Functions

virtual void ejectCasing ()
 
virtual IEnumerator doMuzzleFlash ()
 
virtual IEnumerator animateSlideAndEject ()
 
- Protected Member Functions inherited from BNG.GrabbableEvents
virtual void Awake ()
 

Protected Attributes

bool slideForcedBack = false
 Is the slide / receiver forced back due to last shot.
 
WeaponSlide ws
 
bool readyToShoot = true
 
bool playedEmptySound = false
 
IEnumerator shotRoutine
 
- Protected Attributes inherited from BNG.GrabbableEvents
Grabbable grab
 
Grabber thisGrabber
 
InputBridge input
 

Detailed Description

An example weapon script that can fire Raycasts or Projectile objects.

Member Function Documentation

◆ animateSlideAndEject()

virtual IEnumerator BNG.RaycastWeapon.animateSlideAndEject ( )
protectedvirtual

◆ ApplyParticleFX()

virtual void BNG.RaycastWeapon.ApplyParticleFX ( Vector3  position,
Quaternion  rotation,
Collider  attachTo 
)
virtual

◆ ApplyRecoil()

virtual void BNG.RaycastWeapon.ApplyRecoil ( )
virtual

◆ CheckReloadInput()

virtual void BNG.RaycastWeapon.CheckReloadInput ( )
virtual

◆ doMuzzleFlash()

virtual IEnumerator BNG.RaycastWeapon.doMuzzleFlash ( )
protectedvirtual

◆ ejectCasing()

virtual void BNG.RaycastWeapon.ejectCasing ( )
protectedvirtual

◆ EjectMagazine()

virtual void BNG.RaycastWeapon.EjectMagazine ( )
virtual

◆ GetBulletCount()

virtual int BNG.RaycastWeapon.GetBulletCount ( )
virtual

◆ OnAttachedAmmo()

virtual void BNG.RaycastWeapon.OnAttachedAmmo ( )
virtual

Something attached ammo to us.

◆ OnDetachedAmmo()

virtual void BNG.RaycastWeapon.OnDetachedAmmo ( )
virtual

◆ OnRaycastHit()

virtual void BNG.RaycastWeapon.OnRaycastHit ( RaycastHit  hit)
virtual

◆ OnTrigger()

override void BNG.RaycastWeapon.OnTrigger ( float  triggerValue)
virtual

Amount of Trigger being held down on the grabbed items controller. Only fired if object is being held.

Parameters
triggerValue0 - 1 Open / Closed

Reimplemented from BNG.GrabbableEvents.

◆ OnWeaponCharged()

virtual void BNG.RaycastWeapon.OnWeaponCharged ( bool  allowCasingEject)
virtual

◆ Reload()

virtual void BNG.RaycastWeapon.Reload ( )
virtual

◆ RemoveBullet()

virtual void BNG.RaycastWeapon.RemoveBullet ( )
virtual

◆ Shoot()

virtual void BNG.RaycastWeapon.Shoot ( )
virtual

◆ UnlockSlide()

virtual void BNG.RaycastWeapon.UnlockSlide ( )
virtual

Member Data Documentation

◆ AlwaysFireProjectile

bool BNG.RaycastWeapon.AlwaysFireProjectile = false

◆ AutoChamberRounds

bool BNG.RaycastWeapon.AutoChamberRounds = true

Set true to automatically chamber a new round on fire. False to require charging. Example : Bolt-Action Rifle does not auto chamber.

◆ BulletCasingForce

float BNG.RaycastWeapon.BulletCasingForce = 3f

◆ BulletCasingPrefab

GameObject BNG.RaycastWeapon.BulletCasingPrefab

Eject this at EjectPointTransform (optional)

◆ BulletImpactForce

float BNG.RaycastWeapon.BulletImpactForce = 1000f

◆ BulletInChamber

bool BNG.RaycastWeapon.BulletInChamber = false

Is there currently a bullet chambered and ready to be fired.

◆ ChamberedBullet

Transform BNG.RaycastWeapon.ChamberedBullet

Transform of Chambered Bullet. Hide this when no bullet is chambered.

◆ Damage

float BNG.RaycastWeapon.Damage = 25f

How much damage to apply to "Damageable" on contact.

◆ EjectInput

List<GrabbedControllerBinding> BNG.RaycastWeapon.EjectInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down }

◆ EjectPointTransform

Transform BNG.RaycastWeapon.EjectPointTransform

Where to eject a bullet casing (optional)

◆ EmptyBulletInChamber

bool BNG.RaycastWeapon.EmptyBulletInChamber = false

Is there currently a bullet chambered and that must be ejected.

◆ EmptySound

AudioClip BNG.RaycastWeapon.EmptySound

Play this sound if no ammo and user presses trigger.

◆ EmptySoundVolume

float BNG.RaycastWeapon.EmptySoundVolume = 1f

◆ FireProjectileInSlowMo

bool BNG.RaycastWeapon.FireProjectileInSlowMo = true

◆ FiringMethod

FiringType BNG.RaycastWeapon.FiringMethod = FiringType.Semi

Semi requires user to press trigger repeatedly, Auto to hold down.

◆ FiringRate

float BNG.RaycastWeapon.FiringRate = 0.2f

Ex : 0.2 = 5 Shots per second.

◆ ForceSlideBackOnLastShot

bool BNG.RaycastWeapon.ForceSlideBackOnLastShot = true

Should the slide be forced back if we shoot the last bullet.

◆ GunShotSound

AudioClip BNG.RaycastWeapon.GunShotSound

Play this sound on shoot.

◆ GunShotVolume

float BNG.RaycastWeapon.GunShotVolume = 0.75f

◆ HitFXPrefab

GameObject BNG.RaycastWeapon.HitFXPrefab

Hit Effects spawned at point of impact.

◆ InternalAmmo

float BNG.RaycastWeapon.InternalAmmo = 0

Maximum amount of internal ammo this weapon can hold. Does not account for attached clips. For example, a shotgun has internal ammo.

◆ MaxInternalAmmo

float BNG.RaycastWeapon.MaxInternalAmmo = 10

Maximum amount of internal ammo this weapon can hold. Does not account for attached clips. For example, a shotgun has internal ammo.

◆ MaxRange

float BNG.RaycastWeapon.MaxRange = 25f

How far we can shoot in meters.

◆ MustChamberRounds

bool BNG.RaycastWeapon.MustChamberRounds = false

Does it matter if rounds are chambered or not. Does the user have to charge weapon as soon as ammo is inserted.

◆ MuzzleFlashObject

GameObject BNG.RaycastWeapon.MuzzleFlashObject

Make this active on fire. Randomize scale / rotation.

◆ MuzzlePointTransform

Transform BNG.RaycastWeapon.MuzzlePointTransform

Where our raycast or projectile will spawn from.

◆ onAttachedAmmoEvent

UnityEvent BNG.RaycastWeapon.onAttachedAmmoEvent

◆ onDealtDamageEvent

FloatEvent BNG.RaycastWeapon.onDealtDamageEvent

◆ onDetachedAmmoEvent

UnityEvent BNG.RaycastWeapon.onDetachedAmmoEvent

◆ onRaycastHitEvent

RaycastHitEvent BNG.RaycastWeapon.onRaycastHitEvent

◆ onShootEvent

UnityEvent BNG.RaycastWeapon.onShootEvent

◆ onWeaponChargedEvent

UnityEvent BNG.RaycastWeapon.onWeaponChargedEvent

◆ playedEmptySound

bool BNG.RaycastWeapon.playedEmptySound = false
protected

◆ ProjectilePrefab

GameObject BNG.RaycastWeapon.ProjectilePrefab

If time is slowed this object will be instantiated instead of using a raycast.

◆ readyToShoot

bool BNG.RaycastWeapon.readyToShoot = true
protected

◆ RecoilDuration

float BNG.RaycastWeapon.RecoilDuration = 0.3f

◆ RecoilForce

Vector3 BNG.RaycastWeapon.RecoilForce = Vector3.zero

How much force to apply to the tip of the barrel.

◆ ReleaseSlideInput

List<GrabbedControllerBinding> BNG.RaycastWeapon.ReleaseSlideInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button1Down }

◆ ReloadInput

List<GrabbedControllerBinding> BNG.RaycastWeapon.ReloadInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down }

◆ ReloadMethod

ReloadType BNG.RaycastWeapon.ReloadMethod = ReloadType.InfiniteAmmo

How does the user reload once the Clip is Empty.

◆ ShotForce

float BNG.RaycastWeapon.ShotForce = 10f

◆ shotRoutine

IEnumerator BNG.RaycastWeapon.shotRoutine
protected

◆ SlideDistance

float BNG.RaycastWeapon.SlideDistance = -0.028f

How far back to move the slide on fire.

◆ slideForcedBack

bool BNG.RaycastWeapon.slideForcedBack = false
protected

Is the slide / receiver forced back due to last shot.

◆ slideSpeed

float BNG.RaycastWeapon.slideSpeed = 1

◆ SlideTransform

Transform BNG.RaycastWeapon.SlideTransform

Move this back on fire.

◆ SlowMoRateOfFire

float BNG.RaycastWeapon.SlowMoRateOfFire = 0.3f

◆ TriggerTransform

Transform BNG.RaycastWeapon.TriggerTransform

Transform of trigger to animate rotation of.

◆ ValidLayers

LayerMask BNG.RaycastWeapon.ValidLayers

◆ ws

WeaponSlide BNG.RaycastWeapon.ws
protected

The documentation for this class was generated from the following file: