Corgi Engine  v8.8
MoreMountains.CorgiEngine.WeaponAim Class Reference

Add this component to a Weapon and you'll be able to aim it (meaning you'll rotate it) Supported control modes are mouse, primary movement (you aim wherever you direct your character) and secondary movement (using a secondary axis, separate from the movement). More...

Inheritance diagram for MoreMountains.CorgiEngine.WeaponAim:
MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Types

enum  AimControls {
  AimControls.Off, AimControls.PrimaryMovement, AimControls.SecondaryMovement, AimControls.Mouse,
  AimControls.Script
}
 the list of possible control modes More...
 
enum  RotationModes { RotationModes.Free, RotationModes.Strict4Directions, RotationModes.Strict8Directions }
 the list of possible rotation modes More...
 

Public Member Functions

virtual void SetCurrentAim (Vector3 newAim)
 Aims the weapon towards a new point More...
 
virtual void AddAdditionalAngle (float addedAngle)
 
virtual void ResetAdditionalAngle ()
 

Public Attributes

AimControls AimControl = AimControls.SecondaryMovement
 the aim control mode of choice (off : no control, primary movement (typically your left stick), secondary (right stick), mouse, script : when you want a script to drive your aim (typically for AI, but not only) More...
 
RotationModes RotationMode = RotationModes.Free
 the rotation mode More...
 
float WeaponRotationSpeed = 1f
 the the speed at which the weapon reaches its new position. Set it to zero if you want movement to directly follow input More...
 
bool InstantFlip = false
 if this is true, a flip will be instant, regardless of the weapon rotation speed More...
 
bool PreventAimWhileWeaponIsInUse = false
 if this is true, you won't be able to aim this weapon's aim while it's in use More...
 
float MinimumAngle = -180f
 the minimum angle at which the weapon's rotation will be clamped More...
 
float MaximumAngle = 180f
 the maximum angle at which the weapon's rotation will be clamped More...
 
bool IgnoreSlopeRotation = false
 if this is true, slope rotation will be ignored More...
 
bool IgnoreDownWhenGrounded = false
 if this is true, aiming down won't impact this WeaponAim, similar to how Contra games do it More...
 
GameObject Reticle
 the gameobject to display as the aim's reticle/crosshair. Leave it blank if you don't want a reticle More...
 
bool DisplayReticle = true
 if set to false, the reticle won't be added and displayed More...
 
float ReticleDistance
 the distance at which the reticle will be from the weapon More...
 
float ReticleZPosition
 the z position of the reticle More...
 
bool ReticleAtMousePosition
 if set to true, the reticle will be placed at the mouse's position (like a pointer) More...
 
bool RotateReticle = false
 if set to true, the reticle will rotate on itself to reflect the weapon's rotation. If not it'll remain stable. More...
 
bool ReplaceMousePointer = true
 if set to true, the reticle will replace the mouse pointer More...
 
bool DisableReticleOnDeath = true
 whether or not the reticle should be hidden when the character is dead More...
 

Protected Member Functions

virtual void Start ()
 On Start(), we trigger the initialization More...
 
virtual void Initialization ()
 Grabs the weapon component, initializes the angle values More...
 
virtual void GetCurrentAim ()
 Computes the current aim direction More...
 
virtual void LateUpdate ()
 Every frame, we compute the aim direction and rotate the weapon accordingly More...
 
virtual void ResetCurrentAimMultiplier ()
 Resets the current aim multiplier at the end of the frame More...
 
virtual void DetermineWeaponRotation ()
 Determines the weapon rotation based on the current aim direction More...
 
virtual void RotateWeapon (Quaternion newRotation)
 Rotates the weapon, optionnally applying a lerp to it. More...
 
virtual void InitializeReticle ()
 If a reticle has been set, instantiates the reticle and positions it More...
 
virtual void MoveReticle ()
 Every frame, moves the reticle if it's been told to follow the pointer More...
 
virtual void HideReticle ()
 Handles the hiding of the reticle and cursor More...
 

Protected Attributes

Weapon _weapon
 
List< Weapon_weapons
 
Vector3 _currentAim = Vector3.zero
 
Quaternion _lookRotation
 
Vector3 _direction
 
float[] _possibleAngleValues
 
Vector3 _mousePosition
 
float _additionalAngle
 
Quaternion _initialRotation
 
Camera _mainCamera
 
CharacterGravity _characterGravity
 
CorgiController _controller
 
Vector3 _reticlePosition
 
bool WasFacingRightLastFrame
 
GameObject _reticle
 
Vector2 _regularHorizontalAimMultiplier = new Vector2(1f, 1f)
 

Properties

virtual Quaternion CurrentRotation [get]
 the weapon's current rotation More...
 
float CurrentAngle [get, protected set]
 the current angle the weapon is aiming at More...
 
float CurrentAngleRelative [get]
 the current angle the weapon is aiming at, adjusted to compensate for the current orientation of the character More...
 
Vector2 CurrentAimMultiplier [get, set]
 

Detailed Description

Add this component to a Weapon and you'll be able to aim it (meaning you'll rotate it) Supported control modes are mouse, primary movement (you aim wherever you direct your character) and secondary movement (using a secondary axis, separate from the movement).

Member Enumeration Documentation

◆ AimControls

the list of possible control modes

Enumerator
Off 
PrimaryMovement 
SecondaryMovement 
Mouse 
Script 

◆ RotationModes

the list of possible rotation modes

Enumerator
Free 
Strict4Directions 
Strict8Directions 

Member Function Documentation

◆ AddAdditionalAngle()

virtual void MoreMountains.CorgiEngine.WeaponAim.AddAdditionalAngle ( float  addedAngle)
virtual

◆ DetermineWeaponRotation()

virtual void MoreMountains.CorgiEngine.WeaponAim.DetermineWeaponRotation ( )
protectedvirtual

Determines the weapon rotation based on the current aim direction

◆ GetCurrentAim()

virtual void MoreMountains.CorgiEngine.WeaponAim.GetCurrentAim ( )
protectedvirtual

Computes the current aim direction

◆ HideReticle()

virtual void MoreMountains.CorgiEngine.WeaponAim.HideReticle ( )
protectedvirtual

Handles the hiding of the reticle and cursor

◆ Initialization()

virtual void MoreMountains.CorgiEngine.WeaponAim.Initialization ( )
protectedvirtual

Grabs the weapon component, initializes the angle values

◆ InitializeReticle()

virtual void MoreMountains.CorgiEngine.WeaponAim.InitializeReticle ( )
protectedvirtual

If a reticle has been set, instantiates the reticle and positions it

◆ LateUpdate()

virtual void MoreMountains.CorgiEngine.WeaponAim.LateUpdate ( )
protectedvirtual

Every frame, we compute the aim direction and rotate the weapon accordingly

◆ MoveReticle()

virtual void MoreMountains.CorgiEngine.WeaponAim.MoveReticle ( )
protectedvirtual

Every frame, moves the reticle if it's been told to follow the pointer

◆ ResetAdditionalAngle()

virtual void MoreMountains.CorgiEngine.WeaponAim.ResetAdditionalAngle ( )
virtual

◆ ResetCurrentAimMultiplier()

virtual void MoreMountains.CorgiEngine.WeaponAim.ResetCurrentAimMultiplier ( )
protectedvirtual

Resets the current aim multiplier at the end of the frame

◆ RotateWeapon()

virtual void MoreMountains.CorgiEngine.WeaponAim.RotateWeapon ( Quaternion  newRotation)
protectedvirtual

Rotates the weapon, optionnally applying a lerp to it.

Parameters
newRotationNew rotation.

◆ SetCurrentAim()

virtual void MoreMountains.CorgiEngine.WeaponAim.SetCurrentAim ( Vector3  newAim)
virtual

Aims the weapon towards a new point

Parameters
newAimNew aim.

◆ Start()

virtual void MoreMountains.CorgiEngine.WeaponAim.Start ( )
protectedvirtual

On Start(), we trigger the initialization

Member Data Documentation

◆ _additionalAngle

float MoreMountains.CorgiEngine.WeaponAim._additionalAngle
protected

◆ _characterGravity

CharacterGravity MoreMountains.CorgiEngine.WeaponAim._characterGravity
protected

◆ _controller

CorgiController MoreMountains.CorgiEngine.WeaponAim._controller
protected

◆ _currentAim

Vector3 MoreMountains.CorgiEngine.WeaponAim._currentAim = Vector3.zero
protected

◆ _direction

Vector3 MoreMountains.CorgiEngine.WeaponAim._direction
protected

◆ _initialRotation

Quaternion MoreMountains.CorgiEngine.WeaponAim._initialRotation
protected

◆ _lookRotation

Quaternion MoreMountains.CorgiEngine.WeaponAim._lookRotation
protected

◆ _mainCamera

Camera MoreMountains.CorgiEngine.WeaponAim._mainCamera
protected

◆ _mousePosition

Vector3 MoreMountains.CorgiEngine.WeaponAim._mousePosition
protected

◆ _possibleAngleValues

float [] MoreMountains.CorgiEngine.WeaponAim._possibleAngleValues
protected

◆ _regularHorizontalAimMultiplier

Vector2 MoreMountains.CorgiEngine.WeaponAim._regularHorizontalAimMultiplier = new Vector2(1f, 1f)
protected

◆ _reticle

GameObject MoreMountains.CorgiEngine.WeaponAim._reticle
protected

◆ _reticlePosition

Vector3 MoreMountains.CorgiEngine.WeaponAim._reticlePosition
protected

◆ _weapon

Weapon MoreMountains.CorgiEngine.WeaponAim._weapon
protected

◆ _weapons

List<Weapon> MoreMountains.CorgiEngine.WeaponAim._weapons
protected

◆ AimControl

AimControls MoreMountains.CorgiEngine.WeaponAim.AimControl = AimControls.SecondaryMovement

the aim control mode of choice (off : no control, primary movement (typically your left stick), secondary (right stick), mouse, script : when you want a script to drive your aim (typically for AI, but not only)

◆ DisableReticleOnDeath

bool MoreMountains.CorgiEngine.WeaponAim.DisableReticleOnDeath = true

whether or not the reticle should be hidden when the character is dead

◆ DisplayReticle

bool MoreMountains.CorgiEngine.WeaponAim.DisplayReticle = true

if set to false, the reticle won't be added and displayed

◆ IgnoreDownWhenGrounded

bool MoreMountains.CorgiEngine.WeaponAim.IgnoreDownWhenGrounded = false

if this is true, aiming down won't impact this WeaponAim, similar to how Contra games do it

◆ IgnoreSlopeRotation

bool MoreMountains.CorgiEngine.WeaponAim.IgnoreSlopeRotation = false

if this is true, slope rotation will be ignored

◆ InstantFlip

bool MoreMountains.CorgiEngine.WeaponAim.InstantFlip = false

if this is true, a flip will be instant, regardless of the weapon rotation speed

◆ MaximumAngle

float MoreMountains.CorgiEngine.WeaponAim.MaximumAngle = 180f

the maximum angle at which the weapon's rotation will be clamped

◆ MinimumAngle

float MoreMountains.CorgiEngine.WeaponAim.MinimumAngle = -180f

the minimum angle at which the weapon's rotation will be clamped

◆ PreventAimWhileWeaponIsInUse

bool MoreMountains.CorgiEngine.WeaponAim.PreventAimWhileWeaponIsInUse = false

if this is true, you won't be able to aim this weapon's aim while it's in use

◆ ReplaceMousePointer

bool MoreMountains.CorgiEngine.WeaponAim.ReplaceMousePointer = true

if set to true, the reticle will replace the mouse pointer

◆ Reticle

GameObject MoreMountains.CorgiEngine.WeaponAim.Reticle

the gameobject to display as the aim's reticle/crosshair. Leave it blank if you don't want a reticle

◆ ReticleAtMousePosition

bool MoreMountains.CorgiEngine.WeaponAim.ReticleAtMousePosition

if set to true, the reticle will be placed at the mouse's position (like a pointer)

◆ ReticleDistance

float MoreMountains.CorgiEngine.WeaponAim.ReticleDistance

the distance at which the reticle will be from the weapon

◆ ReticleZPosition

float MoreMountains.CorgiEngine.WeaponAim.ReticleZPosition

the z position of the reticle

◆ RotateReticle

bool MoreMountains.CorgiEngine.WeaponAim.RotateReticle = false

if set to true, the reticle will rotate on itself to reflect the weapon's rotation. If not it'll remain stable.

◆ RotationMode

RotationModes MoreMountains.CorgiEngine.WeaponAim.RotationMode = RotationModes.Free

the rotation mode

◆ WasFacingRightLastFrame

bool MoreMountains.CorgiEngine.WeaponAim.WasFacingRightLastFrame
protected

◆ WeaponRotationSpeed

float MoreMountains.CorgiEngine.WeaponAim.WeaponRotationSpeed = 1f

the the speed at which the weapon reaches its new position. Set it to zero if you want movement to directly follow input

Property Documentation

◆ CurrentAimMultiplier

Vector2 MoreMountains.CorgiEngine.WeaponAim.CurrentAimMultiplier
getset

◆ CurrentAngle

float MoreMountains.CorgiEngine.WeaponAim.CurrentAngle
getprotected set

the current angle the weapon is aiming at

◆ CurrentAngleRelative

float MoreMountains.CorgiEngine.WeaponAim.CurrentAngleRelative
get

the current angle the weapon is aiming at, adjusted to compensate for the current orientation of the character

◆ CurrentRotation

virtual Quaternion MoreMountains.CorgiEngine.WeaponAim.CurrentRotation
get

the weapon's current rotation


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