Third Person Cover Shooter
1.6
|
Guns raycasts bullets, manage magazine and recoil. More...
Public Member Functions | |
void | ToUse () |
Command to use the weapon. More... | |
virtual void | OnMagazineLoadStart () |
Notified of a magazine load start by the CharacterMotor. More... | |
virtual void | OnBulletLoadStart () |
Notified of a magazine load start by the CharacterMotor. More... | |
virtual void | OnPumpStart () |
Notified of a magazine load start by the CharacterMotor. More... | |
virtual void | OnPumped () |
Notified of a magazine load start by the CharacterMotor. More... | |
void | NotifyRechamber () |
void | NotifyEject () |
void | NotifyPumpStart () |
void | NotifyPump () |
void | NotifyMagazineLoadStart () |
void | NotifyBulletLoadStart () |
void | IgnoreSelf (bool value=true) |
Sets the gun to ignore hitting it's owner. More... | |
void | SetFireCondition (int side) |
Sets the gun to not fire if aiming at a friend. More... | |
void | CancelFireCondition () |
Sets the gun to fire in any condition. More... | |
GameObject | FindCurrentAimedTarget () |
Returns a game object the gun is currently aiming at. More... | |
GameObject | FindCurrentAimedHealthTarget () |
Returns a game object with CharacterHealth the gun is currently aiming at. More... | |
abstract bool | LoadMagazine () |
Reload whole magazine. More... | |
abstract bool | LoadBullet () |
Add a single bullet to the magazine. More... | |
RaycastHit | Raycast () |
Finds an object and a hit position a bullet would hit if fired. More... | |
RaycastHit | Raycast (Vector3 origin, Vector3 direction, out bool isFriend, bool friendCheck) |
Finds an object and a hit position a bullet would hit if fired. More... | |
void | TryFireNow () |
Sets the gun to try firing during the next update. More... | |
void | FireWhenReady () |
Sets the fire mode on. More... | |
void | CancelFire () |
Sets the fire mode off. More... | |
void | Allow (bool value) |
Sets whether the gun is allowed to fire. More... | |
void | SetupRaycastThisFrame (Vector3 origin, Vector3 target) |
Sets the position from which bullets are spawned. More... | |
void | AddErrorThisFrame (float degrees) |
Sets the aim error in degrees for the next frame. More... | |
void | SetBaseErrorMultiplierThisFrame (float multiplier) |
Sets the base error (Error property) multiplier for this frame. More... | |
void | UpdateManually () |
Call the update method manually. More... | |
Public Attributes | |
WeaponType | Type = WeaponType.Pistol |
Animations and related assets to be used with this weapon. More... | |
string | Name = "Gun" |
Name of the gun to be display on the HUD. More... | |
float | Zoom = 30 |
How many degrees should the camera FOV be reduced when using scope on the gun. More... | |
Sprite | Scope |
Sprite that's displayed when zooming in. More... | |
float | Rate = 7 |
Rate of fire in shots per second. More... | |
int | BulletsPerShot = 1 |
Bullets fired per single shot. More... | |
bool | ConsumeSingleBulletPerShot = true |
If firing multiple bullets per shot, should only a single bullet be removed from the inventory. More... | |
float | Distance = 50 |
Maximum distance of a bullet hit. More... | |
float | Damage = 10 |
Damage dealt by a single bullet. More... | |
float | Error = 0 |
Maximum degrees of error the gun can make when firing. More... | |
bool | AutoReload = false |
Should the gun be reloaded automatically when the magazine is empty. More... | |
bool | ReloadWithMagazines = true |
Is the gun reloaded with whole magazines or bullet by bullet. More... | |
bool | CanInterruptBulletLoad = true |
If reloading bullet by bullet, can the gun be fired during reload. More... | |
bool | PumpAfterFinalLoad = false |
After a new magazine or the last bullet is loaded, should the gun be pumped. More... | |
bool | PumpAfterBulletLoad = false |
Should the gun be pumped after each bullet load. More... | |
bool | PumpAfterFire = false |
Should the gun be pumped after firing a shot. More... | |
bool | FireOnMobileAim = true |
Will the character fire by just aiming the mobile controller. More... | |
bool | LaserOnlyOnZoom = true |
Should the laser be visible only when zooming. More... | |
bool | DebugAim = false |
Should a debug ray be displayed. More... | |
GameObject | Aim |
Link to the object that controls the aiming direction. More... | |
GameObject | Bullet |
Object to be instantiated as a bullet. More... | |
Transform | LeftHandDefault |
Link to the object that controls the position of character's left hand relative to the weapon. More... | |
float | DamageResponseWaitTime = 1 |
Time in seconds between hits that the target character will respond to with hurt animations. More... | |
bool | UseCustomCrosshair |
Should the gun's crosshair be used instead of the one set in the Crosshair component. More... | |
CrosshairSettings | CustomCrosshair = CrosshairSettings.Default() |
Custom crosshair settings to override the ones set in the Crosshair component. More... | |
GunRecoilSettings | Recoil = GunRecoilSettings.Default() |
Settings that manage gun's recoil behaviour. More... | |
HandOverwrite | LeftHandOverwrite |
Links to objects that overwrite the value in LeftHand based on the gameplay situation. More... | |
Laser | LaserOverwrite |
Force the pistol to use this laser instead of finding one on its own. More... | |
CharacterMotor | Character |
Owning object with a CharacterMotor component. More... | |
Action | MagazineLoadStarted |
Event executed at the beginning of a magazine load animation. More... | |
Action | FullyLoaded |
Event executed after the gun has been fully loaded. More... | |
Action | BulletLoadStarted |
Event executed at the beginning of a bullet load animation. More... | |
Action | BulletLoaded |
Event executed after a bullet has been loaded. More... | |
Action | PumpStarted |
Event executed at the start of a pump animation. More... | |
Action | Pumped |
Event executed at the end of a pump animation. More... | |
Action | Fired |
Event executed after a successful fire. More... | |
Action | EmptyFire |
Event executed every time there is an attempt to fire with no bullets in the gun. More... | |
Action | FireStarted |
Event executed after a series of bullet fires as started. More... | |
Action | FireStopped |
Event executed after a series of bullet fires has stopped. More... | |
Action< Hit > | SuccessfulyHit |
Event executed after a bullet hit something. More... | |
Protected Member Functions | |
virtual void | Start () |
Get the LineRenderer if there is one. More... | |
virtual void | Awake () |
Finds the renderer. More... | |
virtual void | Frame () |
abstract void | Consume () |
Consume a single bullet. More... | |
Properties | |
Vector3 | Origin [get] |
Point of creation for bullets in world space. More... | |
Vector3 | Direction [get] |
Direction of bullets when created at the origin. More... | |
bool | CanHit [get] |
Whether the gun can be used to perform a melee hit right now. More... | |
bool | HasJustFired [get] |
Returns true if the gun fired during the last update. More... | |
bool | IsAllowed [get] |
Returns true if the gun is allowed to fire. More... | |
Renderer | Renderer [get] |
Renderer attached to the object. More... | |
Vector3 | RaycastOrigin [get] |
Origin to cast bullets from. More... | |
Vector3 | RaycastTarget [get] |
Target position at which bullets are fired at. More... | |
bool | HasRaycastSetup [get] |
Are raycast settings setup manually by some other component. More... | |
abstract bool | CanLoad [get] |
Can the gun be loaded with more bullets. More... | |
abstract int | LoadedBulletsLeft [get] |
Number of bullets left in the gun. More... | |
abstract bool | IsFullyLoaded [get] |
Is the gun fully loaded with bullets. More... | |
abstract float | LoadPercentage [get] |
Load percentage for the ammo ui. More... | |
IGunListener [] | Listeners [get] |
Guns raycasts bullets, manage magazine and recoil.
For player characters bullets originate at camera in order for player to be able to fire on targets they can see, even if there is a small obstacle in front of the gun. The fire origin is set by a camera. Since AI do not have Third Person Camera attached their bullets are fired starting from the Aim marker, which usually is at the end of the gun. Each weapon has two marker objects. Aim defines point of origin for AI bullets and is also used when rotating character’s arms till the marker points towards the target. Left Hand object marks the position for character’s left hand. Naming of left and right hands refers to the general case as character’s handedness can be swapped. The intended position of the left hand might differ in some animations, to handle that there are left hand marker overwrites you can use to set up IK for the left hand for some specific situations. Empty values are not used as overwrites. Currently there are two kinds of weapons, pistols and rifles. The type defines character animations when using the weapon.
void CoverShooter.BaseGun.AddErrorThisFrame | ( | float | degrees | ) |
Sets the aim error in degrees for the next frame.
Errors are stacked.
void CoverShooter.BaseGun.Allow | ( | bool | value | ) |
Sets whether the gun is allowed to fire.
Manipulated when changing weapons or a reload animation is playing.
value |
|
protectedvirtual |
Finds the renderer.
void CoverShooter.BaseGun.CancelFire | ( | ) |
Sets the fire mode off.
void CoverShooter.BaseGun.CancelFireCondition | ( | ) |
Sets the gun to fire in any condition.
|
protectedpure virtual |
Consume a single bullet.
Implemented in CoverShooter.Gun.
GameObject CoverShooter.BaseGun.FindCurrentAimedHealthTarget | ( | ) |
Returns a game object with CharacterHealth the gun is currently aiming at.
GameObject CoverShooter.BaseGun.FindCurrentAimedTarget | ( | ) |
Returns a game object the gun is currently aiming at.
void CoverShooter.BaseGun.FireWhenReady | ( | ) |
Sets the fire mode on.
It stays on until CancelFire() is called or the gun has fired. Gun fires only when both fire mode is on and the gun is allowed to fire.
|
protectedvirtual |
void CoverShooter.BaseGun.IgnoreSelf | ( | bool | value = true | ) |
Sets the gun to ignore hitting it's owner.
|
pure virtual |
Add a single bullet to the magazine.
Implemented in CoverShooter.Gun.
|
pure virtual |
Reload whole magazine.
Implemented in CoverShooter.Gun.
void CoverShooter.BaseGun.NotifyBulletLoadStart | ( | ) |
void CoverShooter.BaseGun.NotifyEject | ( | ) |
void CoverShooter.BaseGun.NotifyMagazineLoadStart | ( | ) |
void CoverShooter.BaseGun.NotifyPump | ( | ) |
void CoverShooter.BaseGun.NotifyPumpStart | ( | ) |
void CoverShooter.BaseGun.NotifyRechamber | ( | ) |
|
virtual |
Notified of a magazine load start by the CharacterMotor.
|
virtual |
Notified of a magazine load start by the CharacterMotor.
|
virtual |
Notified of a magazine load start by the CharacterMotor.
|
virtual |
Notified of a magazine load start by the CharacterMotor.
RaycastHit CoverShooter.BaseGun.Raycast | ( | ) |
Finds an object and a hit position a bullet would hit if fired.
RaycastHit CoverShooter.BaseGun.Raycast | ( | Vector3 | origin, |
Vector3 | direction, | ||
out bool | isFriend, | ||
bool | friendCheck | ||
) |
Finds an object and a hit position a bullet would hit if fired.
Checks if it is a friend.
void CoverShooter.BaseGun.SetBaseErrorMultiplierThisFrame | ( | float | multiplier | ) |
Sets the base error (Error property) multiplier for this frame.
void CoverShooter.BaseGun.SetFireCondition | ( | int | side | ) |
Sets the gun to not fire if aiming at a friend.
void CoverShooter.BaseGun.SetupRaycastThisFrame | ( | Vector3 | origin, |
Vector3 | target | ||
) |
Sets the position from which bullets are spawned.
The game usually sets it as the camera position.
|
protectedvirtual |
Get the LineRenderer if there is one.
void CoverShooter.BaseGun.ToUse | ( | ) |
Command to use the weapon.
void CoverShooter.BaseGun.TryFireNow | ( | ) |
Sets the gun to try firing during the next update.
Gun fires only when both fire mode is on and the gun is allowed to fire.
void CoverShooter.BaseGun.UpdateManually | ( | ) |
Call the update method manually.
Performed by the CharacterMotor, in order to fire the weapon after the weapon has performed it's IK.
GameObject CoverShooter.BaseGun.Aim |
Link to the object that controls the aiming direction.
bool CoverShooter.BaseGun.AutoReload = false |
Should the gun be reloaded automatically when the magazine is empty.
GameObject CoverShooter.BaseGun.Bullet |
Object to be instantiated as a bullet.
Action CoverShooter.BaseGun.BulletLoaded |
Event executed after a bullet has been loaded.
Action CoverShooter.BaseGun.BulletLoadStarted |
Event executed at the beginning of a bullet load animation.
int CoverShooter.BaseGun.BulletsPerShot = 1 |
Bullets fired per single shot.
bool CoverShooter.BaseGun.CanInterruptBulletLoad = true |
If reloading bullet by bullet, can the gun be fired during reload.
CharacterMotor CoverShooter.BaseGun.Character |
Owning object with a CharacterMotor component.
bool CoverShooter.BaseGun.ConsumeSingleBulletPerShot = true |
If firing multiple bullets per shot, should only a single bullet be removed from the inventory.
CrosshairSettings CoverShooter.BaseGun.CustomCrosshair = CrosshairSettings.Default() |
Custom crosshair settings to override the ones set in the Crosshair component.
Used only if UseCustomCrosshair is enabled.
float CoverShooter.BaseGun.Damage = 10 |
Damage dealt by a single bullet.
float CoverShooter.BaseGun.DamageResponseWaitTime = 1 |
Time in seconds between hits that the target character will respond to with hurt animations.
bool CoverShooter.BaseGun.DebugAim = false |
Should a debug ray be displayed.
float CoverShooter.BaseGun.Distance = 50 |
Maximum distance of a bullet hit.
Objects further than this value are ignored.
Action CoverShooter.BaseGun.EmptyFire |
Event executed every time there is an attempt to fire with no bullets in the gun.
float CoverShooter.BaseGun.Error = 0 |
Maximum degrees of error the gun can make when firing.
Action CoverShooter.BaseGun.Fired |
Event executed after a successful fire.
bool CoverShooter.BaseGun.FireOnMobileAim = true |
Will the character fire by just aiming the mobile controller.
Action CoverShooter.BaseGun.FireStarted |
Event executed after a series of bullet fires as started.
Action CoverShooter.BaseGun.FireStopped |
Event executed after a series of bullet fires has stopped.
Action CoverShooter.BaseGun.FullyLoaded |
Event executed after the gun has been fully loaded.
bool CoverShooter.BaseGun.LaserOnlyOnZoom = true |
Should the laser be visible only when zooming.
Laser CoverShooter.BaseGun.LaserOverwrite |
Force the pistol to use this laser instead of finding one on its own.
Transform CoverShooter.BaseGun.LeftHandDefault |
Link to the object that controls the position of character's left hand relative to the weapon.
HandOverwrite CoverShooter.BaseGun.LeftHandOverwrite |
Links to objects that overwrite the value in LeftHand based on the gameplay situation.
Action CoverShooter.BaseGun.MagazineLoadStarted |
Event executed at the beginning of a magazine load animation.
string CoverShooter.BaseGun.Name = "Gun" |
Name of the gun to be display on the HUD.
bool CoverShooter.BaseGun.PumpAfterBulletLoad = false |
Should the gun be pumped after each bullet load.
bool CoverShooter.BaseGun.PumpAfterFinalLoad = false |
After a new magazine or the last bullet is loaded, should the gun be pumped.
bool CoverShooter.BaseGun.PumpAfterFire = false |
Should the gun be pumped after firing a shot.
Action CoverShooter.BaseGun.Pumped |
Event executed at the end of a pump animation.
Action CoverShooter.BaseGun.PumpStarted |
Event executed at the start of a pump animation.
float CoverShooter.BaseGun.Rate = 7 |
Rate of fire in shots per second.
GunRecoilSettings CoverShooter.BaseGun.Recoil = GunRecoilSettings.Default() |
Settings that manage gun's recoil behaviour.
bool CoverShooter.BaseGun.ReloadWithMagazines = true |
Is the gun reloaded with whole magazines or bullet by bullet.
Sprite CoverShooter.BaseGun.Scope |
Sprite that's displayed when zooming in.
Action<Hit> CoverShooter.BaseGun.SuccessfulyHit |
Event executed after a bullet hit something.
WeaponType CoverShooter.BaseGun.Type = WeaponType.Pistol |
Animations and related assets to be used with this weapon.
bool CoverShooter.BaseGun.UseCustomCrosshair |
Should the gun's crosshair be used instead of the one set in the Crosshair component.
float CoverShooter.BaseGun.Zoom = 30 |
How many degrees should the camera FOV be reduced when using scope on the gun.
|
get |
Whether the gun can be used to perform a melee hit right now.
|
get |
Can the gun be loaded with more bullets.
|
get |
Direction of bullets when created at the origin.
|
get |
Returns true if the gun fired during the last update.
|
get |
Are raycast settings setup manually by some other component.
|
get |
Returns true if the gun is allowed to fire.
|
get |
Is the gun fully loaded with bullets.
|
getprotected |
|
get |
Number of bullets left in the gun.
|
get |
Load percentage for the ammo ui.
|
get |
Point of creation for bullets in world space.
|
get |
Origin to cast bullets from.
|
get |
Target position at which bullets are fired at.
|
get |
Renderer attached to the object.