![]() |
VR Interaction Framework v2.0
|
An example weapon script that can fire Raycasts or Projectile objects. More...
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< GrabbedControllerBinding > | EjectInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down } |
| List< GrabbedControllerBinding > | ReleaseSlideInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button1Down } |
| List< GrabbedControllerBinding > | ReloadInput = 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 |
An example weapon script that can fire Raycasts or Projectile objects.
|
protectedvirtual |
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
|
protectedvirtual |
|
virtual |
|
virtual |
|
virtual |
Something attached ammo to us.
|
virtual |
|
virtual |
|
virtual |
Amount of Trigger being held down on the grabbed items controller. Only fired if object is being held.
| triggerValue | 0 - 1 Open / Closed |
Reimplemented from BNG.GrabbableEvents.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
| bool BNG.RaycastWeapon.AlwaysFireProjectile = false |
| 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.
| float BNG.RaycastWeapon.BulletCasingForce = 3f |
| GameObject BNG.RaycastWeapon.BulletCasingPrefab |
Eject this at EjectPointTransform (optional)
| float BNG.RaycastWeapon.BulletImpactForce = 1000f |
| bool BNG.RaycastWeapon.BulletInChamber = false |
Is there currently a bullet chambered and ready to be fired.
| Transform BNG.RaycastWeapon.ChamberedBullet |
Transform of Chambered Bullet. Hide this when no bullet is chambered.
| float BNG.RaycastWeapon.Damage = 25f |
How much damage to apply to "Damageable" on contact.
| List<GrabbedControllerBinding> BNG.RaycastWeapon.EjectInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down } |
| Transform BNG.RaycastWeapon.EjectPointTransform |
Where to eject a bullet casing (optional)
| bool BNG.RaycastWeapon.EmptyBulletInChamber = false |
Is there currently a bullet chambered and that must be ejected.
| AudioClip BNG.RaycastWeapon.EmptySound |
Play this sound if no ammo and user presses trigger.
| float BNG.RaycastWeapon.EmptySoundVolume = 1f |
| bool BNG.RaycastWeapon.FireProjectileInSlowMo = true |
| FiringType BNG.RaycastWeapon.FiringMethod = FiringType.Semi |
Semi requires user to press trigger repeatedly, Auto to hold down.
| float BNG.RaycastWeapon.FiringRate = 0.2f |
Ex : 0.2 = 5 Shots per second.
| bool BNG.RaycastWeapon.ForceSlideBackOnLastShot = true |
Should the slide be forced back if we shoot the last bullet.
| AudioClip BNG.RaycastWeapon.GunShotSound |
Play this sound on shoot.
| float BNG.RaycastWeapon.GunShotVolume = 0.75f |
| GameObject BNG.RaycastWeapon.HitFXPrefab |
Hit Effects spawned at point of impact.
| 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.
| 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.
| float BNG.RaycastWeapon.MaxRange = 25f |
How far we can shoot in meters.
| 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.
| GameObject BNG.RaycastWeapon.MuzzleFlashObject |
Make this active on fire. Randomize scale / rotation.
| Transform BNG.RaycastWeapon.MuzzlePointTransform |
Where our raycast or projectile will spawn from.
| UnityEvent BNG.RaycastWeapon.onAttachedAmmoEvent |
| FloatEvent BNG.RaycastWeapon.onDealtDamageEvent |
| UnityEvent BNG.RaycastWeapon.onDetachedAmmoEvent |
| RaycastHitEvent BNG.RaycastWeapon.onRaycastHitEvent |
| UnityEvent BNG.RaycastWeapon.onShootEvent |
| UnityEvent BNG.RaycastWeapon.onWeaponChargedEvent |
|
protected |
| GameObject BNG.RaycastWeapon.ProjectilePrefab |
If time is slowed this object will be instantiated instead of using a raycast.
|
protected |
| float BNG.RaycastWeapon.RecoilDuration = 0.3f |
| Vector3 BNG.RaycastWeapon.RecoilForce = Vector3.zero |
How much force to apply to the tip of the barrel.
| List<GrabbedControllerBinding> BNG.RaycastWeapon.ReleaseSlideInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button1Down } |
| List<GrabbedControllerBinding> BNG.RaycastWeapon.ReloadInput = new List<GrabbedControllerBinding>() { GrabbedControllerBinding.Button2Down } |
| ReloadType BNG.RaycastWeapon.ReloadMethod = ReloadType.InfiniteAmmo |
How does the user reload once the Clip is Empty.
| float BNG.RaycastWeapon.ShotForce = 10f |
|
protected |
| float BNG.RaycastWeapon.SlideDistance = -0.028f |
How far back to move the slide on fire.
|
protected |
Is the slide / receiver forced back due to last shot.
| float BNG.RaycastWeapon.slideSpeed = 1 |
| Transform BNG.RaycastWeapon.SlideTransform |
Move this back on fire.
| float BNG.RaycastWeapon.SlowMoRateOfFire = 0.3f |
| Transform BNG.RaycastWeapon.TriggerTransform |
Transform of trigger to animate rotation of.
| LayerMask BNG.RaycastWeapon.ValidLayers |
|
protected |