using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class customCharacterControllerBase : MonoBehaviour { [Header ("Main Settings")] [Space] public bool characterControllerEnabled = true; public float animatorForwardInputLerpSpeed = 0.1f; public float animatorTurnInputLerpSpeed = 0.1f; public float forwardAmountMultiplier = 1; public bool updateForwardAmountInputValueFromPlayerController; public bool updateTurnAmountInputValueFromPlayerController; public bool updateUsingInputValueFromPlayerController; [Space] public float placeToShootOffset; public bool usePlaceToShootLocalPosition; public Vector3 placeToShootLocalPosition; [Space] [Header ("Collider Settings")] [Space] public bool setCapsuleColliderValues; public Vector3 capsuleColliderCenter; public float capsuleColliderRadius; public float capsuleColliderHeight; public int capsuleColliderDirection = 0; [Space] public bool useExtraColliders; public List extraCollidersList = new List (); public bool setLayerOnExtraCollider = true; [Space] [Header ("Animator Settings")] [Space] public Animator mainAnimator; public RuntimeAnimatorController originalAnimatorController; public Avatar originalAvatar; public Vector3 charactetPositionOffset; public Vector3 characterRotationOffset; [Space] [Header ("Root Motion Settings")] [Space] public bool useRootMotion = true; public float noRootWalkMovementSpeed; public float noRootRunMovementSpeed; public float noRootSprintMovementSpeed; public float noRootCrouchMovementSpeed; public float noRootCrouchRunMovementSpeed = 4; public float noRootWalkStrafeMovementSpeed; public float noRootRunStrafeMovementSpeed; [Space] [Header ("Camera Settings")] [Space] public bool setNewCameraStates; public string newCameraStateThirdPerson; public string newCameraStateFirstPerson; [Space] [Header ("Combat Settings")] [Space] public int combatTypeID; public string playerModeName = "Combat"; [Space] public bool moveDamageTriggersToMainParentsEnabled = true; public Transform parentForCombatDamageTriggers; [Space] public Transform otherPowersShootZoneParent; [Space] [Header ("Abilities Settings")] [Space] public bool setAbilityBrainAttackEnabledState; public bool abilityBrainAttackEnabledState; [Space] public bool setCustomAbilitiesList; public List customAbilitiesList = new List (); [Space] public bool setChangeAbilityAfterTimeEnabledState; public bool changeAbilityAfterTimeEnabledState; [Space] public bool setAbilityByDefault; public string abilityByDefaultName; [Space] [Header ("AI Visibility")] [Space] public bool hiddenFromAIAttacks; [Space] [Header ("AI Settings")] [Space] public bool setAIValues; [Space] public float minRandomTimeBetweenAttacks; public float maxRandomTimeBetweenAttacks; public float minTimeBetweenAttacks; [Space] public float newMinDistanceToEnemyUsingCloseCombat; public float newMinDistanceToCloseCombat; public float raycastPositionOffset = 1; [Space] [Header ("Other Settings")] [Space] public int customActionCategoryID; public float characterRadius; public string customRagdollInfoName; public float healthBarOffset; [Space] [Header ("Ground Adherence Settings")] [Space] public float heightDiffRaycastRadius; public float maxStepHeight; public float newRayDistance = 0; [Space] [Header ("Other Components")] [Space] public List characterMeshesList = new List (); public GameObject characterGameObject; [Space] [Header ("Debug")] [Space] public bool characterControllerActive; public float horizontalInput; public float verticalInput; public bool playerUsingInput; public Vector3 movementInput; public float forwardAmount; public float turnAmount; public bool onGround; public Transform characterTransform; public bool extraCollidersInfoInitialized; public Vector3 originalCharacterPivotTransformPosition; public Transform playerControllerTransform; public bool canMove; public bool ragdollCurrentlyActive; [Space] [Header ("Events Settings")] [Space] public bool useEventsOnStateChange; [Space] public UnityEvent eventOnCharacterControllerActivated; public UnityEvent eventOnCharacterControllerDeactivated; public bool useEventToSendCharacterObjectOnStart; public eventParameters.eventToCallWithGameObject eventToSendCharacterObjectOnStart; public eventParameters.eventToCallWithGameObject eventToSendCharacterObjectOnEnd; public UnityEvent eventOnInstantiateCustomCharacterObject; public virtual void updateCharacterControllerState () { } public virtual void updateCanMoveState (bool state) { canMove = state; } public virtual void setRagdollCurrentlyActiveState (bool state) { ragdollCurrentlyActive = state; } public virtual void updateCharacterControllerAnimator () { } public virtual void updateMovementInputValues (Vector3 newValues) { movementInput = newValues; } public virtual void updateHorizontalVerticalInputValues (Vector2 newValues) { horizontalInput = newValues.x; verticalInput = newValues.y; } public virtual void activateJumpAnimatorState () { } public virtual void updateForwardAmountInputValue (float newValue) { forwardAmount = newValue * forwardAmountMultiplier; } public virtual void updateTurnAmountInputValue (float newValue) { turnAmount = newValue; } public virtual void updateOnGroundValue (bool state) { onGround = state; } public virtual void updatePlayerUsingInputValue (bool state) { playerUsingInput = state; } public virtual void setForwardAmountMultiplierValue (float newValue) { forwardAmountMultiplier = newValue; } public virtual void resetAnimatorState () { } public virtual void setCharacterControllerActiveState (bool state) { if (!characterControllerEnabled) { return; } characterControllerActive = state; checkEventsOnStateChange (characterControllerActive); enableOrDisableCharacterMeshesList (state); } public virtual void enableOrDisableCharacterMeshesList (bool state) { for (int i = 0; i < characterMeshesList.Count; i++) { if (characterMeshesList [i] != null) { if (characterMeshesList [i].activeSelf != state) { characterMeshesList [i].SetActive (state); } } } } public virtual void setOriginalCharacterGameObjectTransformPosition (Vector3 newValue) { originalCharacterPivotTransformPosition = newValue; } public virtual void setPlayerControllerTransform (Transform newTransform) { playerControllerTransform = newTransform; } public virtual void setCharacterTransform (Transform newTransform) { characterTransform = newTransform; } public void checkEventsOnStateChange (bool state) { if (useEventsOnStateChange) { if (state) { eventOnCharacterControllerActivated.Invoke (); } else { eventOnCharacterControllerDeactivated.Invoke (); } } if (useEventToSendCharacterObjectOnStart) { if (state) { eventToSendCharacterObjectOnStart.Invoke (characterGameObject); } else { eventToSendCharacterObjectOnEnd.Invoke (characterGameObject); } } } public void updateAnimatorFloatValue (int animatorIDValue, float floatValue) { mainAnimator.SetFloat (animatorIDValue, floatValue); } public void updateAnimatorIntegerValue (int animatorIDValue, int intValue) { mainAnimator.SetInteger (animatorIDValue, intValue); } public void updateAnimatorBoolValue (int animatorIDValue, bool boolValue) { mainAnimator.SetBool (animatorIDValue, boolValue); } public void updateAnimatorFloatValueLerping (int animatorIDValue, float floatValue, float animatorLerpSpeed, float currentFixedUpdateDeltaTime) { mainAnimator.SetFloat (animatorIDValue, floatValue, animatorLerpSpeed, currentFixedUpdateDeltaTime); } //Collider Settings public void setCapsuleColliderDirectionValue (float newValue) { capsuleColliderDirection = (int)newValue; } public void setCapsuleColliderCenterValue (Vector3 newValue) { capsuleColliderCenter = newValue; } public void setCapsuleColliderRadiusValue (float newValue) { capsuleColliderRadius = newValue; } public void setCapsuleColliderHeightValue (float newValue) { capsuleColliderHeight = newValue; } public void setPlaceToShootOffsetValue (float newValue) { placeToShootOffset = newValue; } //Animator Settings public void setCharactetPositionOffsetValue (Vector3 newValue) { charactetPositionOffset = newValue; } public void setCharacterRotationOffsetValue (Vector3 newValue) { characterRotationOffset = newValue; } //Root Motion Settings public void setUseRootMotionValue (bool state) { useRootMotion = state; } public void setNoRootWalkMovementSpeedValue (float newValue) { noRootWalkMovementSpeed = newValue; } public void setNoRootRunMovementSpeedValue (float newValue) { noRootRunMovementSpeed = newValue; } public void setNoRootSprintMovementSpeedValue (float newValue) { noRootSprintMovementSpeed = newValue; } public void setNoRootCrouchMovementSpeedValue (float newValue) { noRootCrouchMovementSpeed = newValue; } public void setNoRootWalkStrafeMovementSpeedValue (float newValue) { noRootWalkStrafeMovementSpeed = newValue; } public void setNoRootRunStrafeMovementSpeedValue (float newValue) { noRootRunStrafeMovementSpeed = newValue; } //Camera Settings public void setSetNewCameraStatesValue (bool state) { setNewCameraStates = state; } public void setNewCameraStateThirdPersonValue (string newValue) { newCameraStateThirdPerson = newValue; } public void setNewCameraStateFirstPersonValue (string newValue) { newCameraStateFirstPerson = newValue; } //Other Settings public void setCustomActionCategoryIDValue (float newValue) { customActionCategoryID = (int)newValue; } public void setCharacterRadiusValue (float newValue) { characterRadius = newValue; } public void setCombatTypeIDValue (float newValue) { combatTypeID = (int)newValue; } public void setCustomRagdollInfoNameValue (string newValue) { customRagdollInfoName = newValue; } public void setPlayerModeNameValue (string newValue) { playerModeName = newValue; } public void setHealthBarOffsetValue (float newValue) { healthBarOffset = newValue; } //AI Visibility public void setHiddenFromAIAttacksValue (bool state) { hiddenFromAIAttacks = state; } //AI Settings public void setSetAIValuesValue (bool state) { setAIValues = state; } public void setMaxRandomTimeBetweenAttacksValue (float newValue) { maxRandomTimeBetweenAttacks = newValue; } public void setMinRandomTimeBetweenAttacksValue (float newValue) { minRandomTimeBetweenAttacks = newValue; } public void setNewMinDistanceToEnemyUsingCloseCombatValue (float newValue) { newMinDistanceToEnemyUsingCloseCombat = newValue; } public void setNewMinDistanceToCloseCombatValue (float newValue) { newMinDistanceToCloseCombat = newValue; } public void setRaycastPositionOffsetValue (float newValue) { raycastPositionOffset = newValue; } }