Loading...
Searching...
No Matches
AdventureCore.CharacterControllerMovement Class Reference

Detailed Description

a movement implementation that is built on top of the unity CharacterController
meant for player movement it accepts input in OnMove(Vector2) and OnSprint(bool)

https://adventure.softleitner.com/manual/character

Inheritance diagram for AdventureCore.CharacterControllerMovement:
AdventureCore.MovementBasePersisted AdventureCore.MovementBase

Public Member Functions

void OnMove (InputAction.CallbackContext callbackContext)
 
void OnMove (InputValue value)
 
virtual void OnMove (Vector2 value)
 
void OnSprint (InputAction.CallbackContext callbackContext)
 
void OnSprint (InputValue value)
 
virtual void OnSprint (bool value)
 
void OnJump (InputAction.CallbackContext callbackContext)
 
void OnJump (InputValue value)
 
virtual void OnJump (float strength)
 
override void SetTarget (Transform transform)
 
override void ResetInput ()
 resets current input to the model direction(for example when coming out of an animation)
 
override void ResetMomentum ()
 resets the movements momentum(gravity, velocity)
 
override void AlignToInput ()
 quickly aligns the movement with the input direction(in between rolls for example)
 
override bool AdvanceMarch (Vector3 a, Vector3 b, float normalizedTime, float delta, float multiplier=1)
 
override bool AdvanceMarch (Vector3 target, float deltaTime, float multiplier=1)
 
override void TeleportCharacter (Vector3 position, Quaternion rotation)
 instantly moves the character
 
override void PropelCharacter (Vector3 value)
 
override void ApplyRootMotion (Animator animator)
 
- Public Member Functions inherited from AdventureCore.MovementBasePersisted
void Set ()
 
void Set (Vector3 position, Quaternion rotation, Quaternion cameraRotation)
 
override void SetPersisted (Vector3 position, Quaternion rotation)
 
- Public Member Functions inherited from AdventureCore.MovementBase
virtual Quaternion GetOffsetRotation (float horizontal, float vertical)
 
virtual void SetTarget (Component component)
 
virtual void Align (Vector3 direction)
 quickly aligns the movement with a give direction
 
virtual void AlignToTarget ()
 quickly aligns the movement with its Target, this may be a locked on enemy or the target an AI is following
 
virtual void KeepAligned (Vector3 direction)
 keeps the movement aligned with a give direction
 
virtual void KeepAlignedToInput ()
 keeps the movement aligned with the input direction
 
virtual void KeepAlignedToTarget ()
 keeps the movement aligned with its Target, this may be a locked on enemy or the target an AI is following
 
virtual void StartMarch ()
 
virtual void EndMarch ()
 
virtual void TeleportCharacter (Transform transform)
 instantly moves the character to a transform
 
virtual void MoveCharacter (Transform transform)
 quickly moves the movement to the passed transform
 
virtual void MoveCharacter (Vector3 position, Quaternion rotation)
 
virtual void PropelCharacterLocal (Vector3 value)
 
void SetPersisted (Transform transform)
 

Public Attributes

Transform Pivot
 
Transform Camera
 
float SpeedRunning = 5
 
float SpeedSprinting = 10
 
float JumpHeight = 1.2f
 
float Gravity = -15.0f
 
float PushPower = 2.0f
 
float WeightPower = 0.0f
 
CharacterActionBase Turn
 
UnityEvent Jumping
 
UnityEvent< float > Fallen
 
UnityEvent Teleported
 
bool GroundingSphere
 
float GroundingSphereRadius = 0.25f
 
float GroundingSphereOffset
 
LayerMask GroundingSphereLayers
 
- Public Attributes inherited from AdventureCore.MovementBasePersisted
PersisterBase Persister
 
float Interval = 1f
 
Transform CameraPivot
 
UnityEvent Persisted
 

Protected Member Functions

override void Awake ()
 
override void Update ()
 
override IEnumerator moveCharacter (Vector3 position, Quaternion rotation)
 
- Protected Member Functions inherited from AdventureCore.MovementBase
virtual IEnumerator align (float target, Action finished=null, bool waitForEndOfFrame=false)
 
virtual void keepAligned (float rotation)
 

Properties

override bool IsCollisionSuspended [get, set]
 
bool IsSprintingSuspended [get, set]
 
override Vector3 Position [get, set]
 
override Vector3 Direction [get]
 
override Vector3 Velocity [get]
 
override bool _isPersistenceActive [get]
 
override Transform RotationPivot [get]
 
- Properties inherited from AdventureCore.MovementBasePersisted
virtual bool _isPersistenceActive [get]
 
- Properties inherited from AdventureCore.MovementBase
virtual bool IsTranslationSuspended [get, set]
 means that no translation should be applied by the movement
 
virtual bool IsRotationSuspended [get, set]
 means that no rotation should be applied by the movement
 
virtual bool IsControlSuspended [get, set]
 while this is true input will have no influence on the movement(rolling for example)
 
virtual bool IsCollisionSuspended [get, set]
 suspends collision of the player with environment and such, for example when the player is moved through a tight crack by an animation or climbing a ladder
 
virtual bool IsPersistenceSuspended [get, set]
 notifies the movement that its position should not be persisted(perhaps because the area is unsafe or moving)
 
virtual float SpeedMultiplier = 1f [get, set]
 can be used to modify the movements speed from outside(for example slowed by snow or boosted by some effect)
 
virtual Vector3 MotionMultiplier = Vector3.one [get, set]
 can be used to modify the movement from root motion from outside(may be useful when characters of different sizes use the same animation)
 
virtual float SpeedFactorForward [get, protected set]
 how fast the character is moving forwards relative to its maximum speed
so 1 means full speed forward -0.5 is moving back at half speed and 2 could be a sprint forward
can be used as a parameter for walking animations and leaning according to speed
 
virtual float SpeedFactorSideways [get, protected set]
 how fast the character is moving sideways relative to its maximum speed
characters may move sideways when locked on for example
1 could mean full speed right, -0.5 half speed left
can be used as a parameter for walking animations and leaning according to speed
 
virtual bool IsGrounded = true [get, protected set]
 whether the character is currently touching the ground
useful for switching to a falling animation or to check if jumping is possible
 
virtual bool IsSprinting [get, protected set]
 whether the character is currently sprinting
 
virtual bool IsMarching [get, protected set]
 whether the character is currently marching
 
virtual bool IsMoved [get, protected set]
 whether the character is currently being forced to move using MoveCharacter(Transform)
 
virtual Transform Target [get]
 
virtual bool HasTarget [get]
 
virtual float TargetDistance [get]
 
virtual Vector3 TargetDirection [get]
 
virtual Vector3 Position [get, set]
 
virtual Quaternion Rotation [get, set]
 
virtual Vector3 Forward [get, set]
 
virtual Vector3 Right [get, set]
 
virtual Vector3 Up [get, set]
 
virtual Vector3 Direction [get]
 
virtual Vector3 Velocity [get]
 
virtual bool IsMoving [get]
 
virtual Transform RotationPivot [get]
 
virtual float AlignmentDuration [get]
 

Additional Inherited Members

- Static Public Attributes inherited from AdventureCore.MovementBasePersisted
const string PERSISTENCE_SUB_KEY = "MOV"
 
- Static Protected Member Functions inherited from AdventureCore.MovementBase
static IEnumerator tween (Action< float > change, Action finished, float duration, bool waitForEndOfFrame=false)
 
- Events inherited from AdventureCore.MovementBase
Action< Transform > TargetChanged
 

Member Function Documentation

◆ AdvanceMarch() [1/2]

override bool AdventureCore.CharacterControllerMovement.AdvanceMarch ( Vector3 a,
Vector3 b,
float normalizedTime,
float delta,
float multiplier = 1 )
inlinevirtual

Reimplemented from AdventureCore.MovementBase.

◆ AdvanceMarch() [2/2]

override bool AdventureCore.CharacterControllerMovement.AdvanceMarch ( Vector3 target,
float deltaTime,
float multiplier = 1 )
inlinevirtual

Reimplemented from AdventureCore.MovementBase.

◆ AlignToInput()

override void AdventureCore.CharacterControllerMovement.AlignToInput ( )
virtual

quickly aligns the movement with the input direction(in between rolls for example)

Reimplemented from AdventureCore.MovementBase.

◆ ApplyRootMotion()

override void AdventureCore.CharacterControllerMovement.ApplyRootMotion ( Animator animator)
inlinevirtual

Reimplemented from AdventureCore.MovementBase.

◆ Awake()

override void AdventureCore.CharacterControllerMovement.Awake ( )
inlineprotectedvirtual

◆ moveCharacter()

override IEnumerator AdventureCore.CharacterControllerMovement.moveCharacter ( Vector3 position,
Quaternion rotation )
inlineprotectedvirtual

Reimplemented from AdventureCore.MovementBase.

◆ PropelCharacter()

override void AdventureCore.CharacterControllerMovement.PropelCharacter ( Vector3 value)
inlinevirtual

Reimplemented from AdventureCore.MovementBase.

◆ ResetInput()

override void AdventureCore.CharacterControllerMovement.ResetInput ( )
inlinevirtual

resets current input to the model direction(for example when coming out of an animation)

Reimplemented from AdventureCore.MovementBase.

◆ ResetMomentum()

override void AdventureCore.CharacterControllerMovement.ResetMomentum ( )
inlinevirtual

resets the movements momentum(gravity, velocity)

Reimplemented from AdventureCore.MovementBase.

◆ SetTarget()

override void AdventureCore.CharacterControllerMovement.SetTarget ( Transform transform)
inlinevirtual

Reimplemented from AdventureCore.MovementBase.

◆ TeleportCharacter()

override void AdventureCore.CharacterControllerMovement.TeleportCharacter ( Vector3 position,
Quaternion rotation )
inlinevirtual

instantly moves the character

Parameters
positionposition the character is teleported to
rotationrotation the character is teleported to

Reimplemented from AdventureCore.MovementBase.

◆ Update()

override void AdventureCore.CharacterControllerMovement.Update ( )
inlineprotectedvirtual