๐Ÿ”ซAuto Gun

Auto Gun component will manage shooting, ammo, and slide reloading logic. Auto Gun system includes built in logic for Auto Ammo, Auto Gun Target, Auto Gun Effects

The gun takes a Place Point called Magazine Point that should be configured to take the appropriate grabbables with the Auto Ammo component.

The gun does not keep track of its ammo directly it only knows if it has one bullet in the chamber or not, and if it has an Auto Ammo placed in its Magazine Point

If an Auto Ammo is place in this point you can call the AutoGun.LoadSlide() event from a function or from a Unity Event to load that first bullet into the Auto Gun (in the Demo the rifle's slide uses a GrabbableHeldJoint component which calls the LoadSlide() event from it's Unity Event)

Shooting the gun will automatically reload the slide until there is no more ammo in the Auto Ammo or if the clip has been removed

Shoot Forward Determines the origin and direction for bullet raycasting, essential for calculating bullet paths.

Slide Joint (Optional) Grabbable Held Joint is recommended for triggering the LoadSlide() event, if connected this will trigger the slide movement when shooting. (Check the events on the rifle slide in the demo for example)

Magazine Point The place point for the ammo, this Place Point should only take objects this gun considers ammo. Ammo grabbables should always include the Auto Ammo component

Automatic Fire Rate how quickly the gun will repeat fire, in seconds, while holding down the trigger. Set to 0 for semi-automatic

Hit Force The physics force applied to the target's rigidbody when hit

Kick Back Force The physics force applied to the gun when shooting

Use Bullet Penetration If true the gun will hit every target until it hits a static collider

Require Slide Loading whether or not the LoadSlide() function needs to be called externally or if it is automatically called when the ammo is loaded

Auto Eject Empty Clip Whether or not the ammo clip should automatically be removed from the place point when it's empty

Gun Events

On Shoot called when the gun is successfully shot, using an ammo

On Empty Shoot called when the shoot event is called but there is no ammo

On Hit when a target is hit

On Ammo Place called when a new ammo is placed in the ammo place point

On Ammo Remove called when a new ammo is removed from the ammo place point

On Slide Load called when the LoadSlide() or FireLoadSlide() function is called. Includes an enum to distiguish between a hand load event and a fire load event

Auto Ammo

This component should be attached to any object being used in the Gun's attached Magazine Point Place Point. Without this component the placed object won't be considered valid ammo

Current Ammo The current amount of ammo left in this clip

Ammo Text Updates to show the ammo count whenever it changes

Auto Gun Effects

This is an additional component that can be added onto the Auto Gun to add additional visual/audio details without coding a new script. This script is not required and does not change how the core gun works

Eject Unfired Bullet Whether or not racking the slide with a bullet already in the chamber ejects that bullet or not

Bullet This is the unfired bullet prefab that will be instantiated and ejected if the 'ejectUnfiredBullet' value is true and the slide is racked while full

Bullet Shell This is the fired bullet shell prefab that will be instantiated and ejected when the gun is shot

Shoot Particle This is the fired bullet shell prefab that will be instantiated and ejected if the when the gun is shot

Ejected Bullet Lifetime The lifetime of the ejected bullets before they are added to the pool

Shell Ejection Spawn Point The position and rotation where the bullets are instantiated

Shell Ejection Direction The forward direction of this point represents the direction the shells should be ejected

Shell Ejection Force The amount of force to add to the ejected bullet

Shoot Sound This sound will play when a bullet is fired

Empty Shoot Sound This sound will play when a the trigger is pressed and there is nothing to shoot

Last updated