add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class AIMountManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool mountManagerEnabled = true;
|
||||
|
||||
public string remoteEventToCallAIMount = "Set Player As Target For Mount AI";
|
||||
|
||||
public string remoteEventToAssignAIMount = "Assign Player To Mount AI";
|
||||
|
||||
public float minDistanceToCallAIMount = 20;
|
||||
|
||||
public float minDistanceToTeleportAIMount = 100;
|
||||
|
||||
public LayerMask layerToTeleportRaycast;
|
||||
|
||||
public float raycastDistance;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnCallAIMount;
|
||||
|
||||
public UnityEvent eventOnTeleportAIMountBefore;
|
||||
public UnityEvent eventOnTeleportAIMountAfter;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
public bool currentMountAssigned;
|
||||
|
||||
public GameObject currentMountGameObject;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public Transform teleportAIMountTargetTransform;
|
||||
|
||||
public Transform playerTransform;
|
||||
|
||||
playerController mountPlayerController;
|
||||
|
||||
Transform currentMountTransform;
|
||||
|
||||
float lastTimeAIMountAssigned;
|
||||
|
||||
remoteEventSystem currentRemoteEventSystem;
|
||||
|
||||
public void assignCurrentMountGameObject (GameObject newObject)
|
||||
{
|
||||
if (!mountManagerEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
StartCoroutine (assignCurrentMountGameObjectCoroutine (newObject));
|
||||
}
|
||||
|
||||
IEnumerator assignCurrentMountGameObjectCoroutine (GameObject newObject)
|
||||
{
|
||||
yield return new WaitForSeconds (0.01f);
|
||||
|
||||
mountPlayerController = newObject.GetComponentInChildren<playerController> ();
|
||||
|
||||
if (mountPlayerController != null) {
|
||||
currentMountGameObject = mountPlayerController.gameObject;
|
||||
|
||||
currentMountTransform = currentMountGameObject.transform;
|
||||
|
||||
currentRemoteEventSystem = currentMountGameObject.GetComponent<remoteEventSystem> ();
|
||||
|
||||
if (currentRemoteEventSystem != null) {
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (remoteEventToAssignAIMount, playerTransform.gameObject);
|
||||
}
|
||||
|
||||
currentMountAssigned = true;
|
||||
|
||||
lastTimeAIMountAssigned = Time.time;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Mount Assigned " + currentMountGameObject.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCurrentMountGameObject ()
|
||||
{
|
||||
if (currentMountAssigned) {
|
||||
mountPlayerController = null;
|
||||
|
||||
currentMountGameObject = null;
|
||||
|
||||
currentMountAssigned = false;
|
||||
|
||||
lastTimeAIMountAssigned = 0;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Mount removed ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void callCurrentMount ()
|
||||
{
|
||||
if (!mountManagerEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentMountAssigned) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time.time < lastTimeAIMountAssigned + 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentMountGameObject == null || applyDamage.checkIfDeadOnObjectChilds (currentMountGameObject)) {
|
||||
removeCurrentMountGameObject ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Mount is dead, removing ");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool mountAICalled = false;
|
||||
|
||||
float distanceToPlayer = GKC_Utils.distance (playerTransform.position, currentMountGameObject.transform.position);
|
||||
|
||||
if (distanceToPlayer < minDistanceToCallAIMount) {
|
||||
if (currentRemoteEventSystem != null) {
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (remoteEventToCallAIMount, playerTransform.gameObject);
|
||||
|
||||
mountAICalled = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Calling mount from distance on navmesh");
|
||||
}
|
||||
}
|
||||
} else if (distanceToPlayer < minDistanceToTeleportAIMount) {
|
||||
eventOnTeleportAIMountBefore.Invoke ();
|
||||
|
||||
Vector3 targetPosition = teleportAIMountTargetTransform.position;
|
||||
Quaternion targetRotation = teleportAIMountTargetTransform.rotation;
|
||||
|
||||
RaycastHit hit = new RaycastHit ();
|
||||
|
||||
if (Physics.Raycast (targetPosition, -Vector3.up, out hit, raycastDistance, layerToTeleportRaycast)) {
|
||||
targetPosition = hit.point + hit.normal * 0.1f;
|
||||
}
|
||||
|
||||
currentMountTransform.position = targetPosition;
|
||||
currentMountTransform.rotation = targetRotation;
|
||||
|
||||
currentRemoteEventSystem.callRemoteEventWithGameObject (remoteEventToCallAIMount, playerTransform.gameObject);
|
||||
|
||||
mountAICalled = true;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("teleporting mount");
|
||||
}
|
||||
|
||||
eventOnTeleportAIMountAfter.Invoke ();
|
||||
}
|
||||
|
||||
if (mountAICalled) {
|
||||
eventOnCallAIMount.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6df7400d4652e3f46b3b47c62d05e975
|
||||
timeCreated: 1636372509
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/AIMountManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,102 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GKCCharacterController : playerController
|
||||
{
|
||||
[Space]
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public customCharacterControllerBase mainCustomCharacterControllerBase;
|
||||
|
||||
bool characterInitialized;
|
||||
|
||||
Vector2 customAxisValues;
|
||||
Vector2 customRawAxisValues;
|
||||
|
||||
void OnEnable ()
|
||||
{
|
||||
if (characterInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
StartCoroutine (startGameWithCustomCharacterControllerCoroutine ());
|
||||
|
||||
characterInitialized = true;
|
||||
}
|
||||
|
||||
IEnumerator startGameWithCustomCharacterControllerCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.3f);
|
||||
|
||||
mainCustomCharacterControllerBase.setCharacterControllerActiveState (true);
|
||||
|
||||
mainCustomCharacterControllerBase.updateOnGroundValue (isPlayerOnGround ());
|
||||
|
||||
setCustomCharacterControllerActiveState (true, mainCustomCharacterControllerBase);
|
||||
|
||||
animator.runtimeAnimatorController = mainCustomCharacterControllerBase.originalAnimatorController;
|
||||
animator.avatar = mainCustomCharacterControllerBase.originalAvatar;
|
||||
|
||||
if (mainCustomCharacterControllerBase.setCapsuleColliderValues) {
|
||||
setPlayerColliderCapsuleScale (mainCustomCharacterControllerBase.capsuleColliderHeight);
|
||||
|
||||
setPlayerCapsuleColliderDirection (mainCustomCharacterControllerBase.capsuleColliderDirection);
|
||||
|
||||
setPlayerColliderCapsuleCenter (mainCustomCharacterControllerBase.capsuleColliderCenter);
|
||||
|
||||
setPlayerCapsuleColliderRadius (mainCustomCharacterControllerBase.capsuleColliderRadius);
|
||||
}
|
||||
|
||||
setCharacterMeshGameObjectState (false);
|
||||
|
||||
setCharacterMeshesListToDisableOnEventState (false);
|
||||
}
|
||||
|
||||
public override void setCustomAxisValues (Vector2 newValue)
|
||||
{
|
||||
customAxisValues = newValue;
|
||||
|
||||
if (customAxisValues.x > 0) {
|
||||
customRawAxisValues.x = 1;
|
||||
} else if (customAxisValues.x < 0) {
|
||||
customRawAxisValues.x = -1;
|
||||
} else {
|
||||
customRawAxisValues.x = 0;
|
||||
}
|
||||
|
||||
if (customAxisValues.y > 0) {
|
||||
customRawAxisValues.y = 1;
|
||||
} else if (customAxisValues.y < 0) {
|
||||
customRawAxisValues.y = -1;
|
||||
} else {
|
||||
customRawAxisValues.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void setMainAxisValues ()
|
||||
{
|
||||
axisValues = customAxisValues;
|
||||
}
|
||||
|
||||
public override void setMainRawAxisValues ()
|
||||
{
|
||||
rawAxisValues = customRawAxisValues;
|
||||
}
|
||||
|
||||
public override void setAIMainAxisValues ()
|
||||
{
|
||||
axisValues = customAxisValues;
|
||||
}
|
||||
|
||||
public override void setMainAIRawAxisValues ()
|
||||
{
|
||||
rawAxisValues = customRawAxisValues;
|
||||
}
|
||||
|
||||
public override void updateOverrideInputValues (Vector2 inputValues, bool state)
|
||||
{
|
||||
// playerInput.overrideInputValues (inputValues, state);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eda91f1a19d0d0f4ea08d5aaee031f96
|
||||
timeCreated: 1630672236
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/GKCCharacterController.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,125 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class basicAnimatorController : customCharacterControllerBase
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public string horizontalAnimatorName = "Horizontal";
|
||||
public string verticalAnimatorName = "Vertical";
|
||||
public string stateAnimatorName = "State";
|
||||
|
||||
public string groundedStateAnimatorName = "Grounded";
|
||||
public string movementAnimatorName = "Movement";
|
||||
public string speedMultiplierAnimatorName = "SpeedMultiplier";
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public int jumpState = 2;
|
||||
public int movementState = 1;
|
||||
public int fallState = 3;
|
||||
public int deathState = 10;
|
||||
|
||||
public int currentState;
|
||||
|
||||
int horizontalAnimatorID;
|
||||
int verticalAnimatorID;
|
||||
|
||||
int stateAnimatorID;
|
||||
int groundedStateAnimatorID;
|
||||
|
||||
int movementAnimatorID;
|
||||
|
||||
bool valuesInitialized;
|
||||
|
||||
void Start ()
|
||||
{
|
||||
initialiveValues ();
|
||||
}
|
||||
|
||||
void initialiveValues ()
|
||||
{
|
||||
if (!valuesInitialized) {
|
||||
horizontalAnimatorID = Animator.StringToHash (horizontalAnimatorName);
|
||||
verticalAnimatorID = Animator.StringToHash (verticalAnimatorName);
|
||||
|
||||
stateAnimatorID = Animator.StringToHash (stateAnimatorName);
|
||||
groundedStateAnimatorID = Animator.StringToHash (groundedStateAnimatorName);
|
||||
movementAnimatorID = Animator.StringToHash (movementAnimatorName);
|
||||
|
||||
valuesInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateCharacterControllerState ()
|
||||
{
|
||||
updateAnimatorFloatValueLerping (horizontalAnimatorID, turnAmount, animatorTurnInputLerpSpeed, Time.fixedDeltaTime);
|
||||
|
||||
updateAnimatorFloatValueLerping (verticalAnimatorID, forwardAmount, animatorForwardInputLerpSpeed, Time.fixedDeltaTime);
|
||||
|
||||
updateAnimatorBoolValue (groundedStateAnimatorID, onGround);
|
||||
|
||||
updateAnimatorBoolValue (movementAnimatorID, playerUsingInput);
|
||||
}
|
||||
|
||||
public override void updateCharacterControllerAnimator ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void updateMovementInputValues (Vector3 newValues)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void updateHorizontalVerticalInputValues (Vector2 newValues)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void activateJumpAnimatorState ()
|
||||
{
|
||||
updateAnimatorIntegerValue (stateAnimatorID, jumpState);
|
||||
|
||||
currentState = jumpState;
|
||||
}
|
||||
|
||||
public override void updateOnGroundValue (bool state)
|
||||
{
|
||||
base.updateOnGroundValue (state);
|
||||
|
||||
if (currentState == 1) {
|
||||
if (!onGround) {
|
||||
updateAnimatorIntegerValue (stateAnimatorID, 3);
|
||||
|
||||
currentState = 3;
|
||||
}
|
||||
} else {
|
||||
if (onGround) {
|
||||
updateAnimatorIntegerValue (stateAnimatorID, 1);
|
||||
|
||||
currentState = 1;
|
||||
} else {
|
||||
|
||||
// if (currentState == 2) {
|
||||
// updateAnimatorIntegerValue (stateAnimatorID, 20);
|
||||
//
|
||||
// currentState = 20;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void setCharacterControllerActiveState (bool state)
|
||||
{
|
||||
base.setCharacterControllerActiveState (state);
|
||||
|
||||
if (state) {
|
||||
initialiveValues ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9350a7221815ae45a9785310f96d809
|
||||
timeCreated: 1629368377
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/basicAnimatorController.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,529 @@
|
||||
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<Collider> extraCollidersList = new List<Collider> ();
|
||||
|
||||
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<string> customAbilitiesList = new List<string> ();
|
||||
|
||||
[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<GameObject> characterMeshesList = new List<GameObject> ();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4eec8819e94bd5249aaf8286a52d11d6
|
||||
timeCreated: 1629077631
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/customCharacterControllerBase.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,107 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class customCharacterControllerBaseBuilder : MonoBehaviour
|
||||
{
|
||||
public List<buildPlayer.settingsInfoCategory> settingsInfoCategoryList = new List<buildPlayer.settingsInfoCategory> ();
|
||||
|
||||
public customCharacterControllerBase mainCustomCharacterControllerBase;
|
||||
|
||||
buildPlayer.settingsInfo currentSettingsInfo;
|
||||
buildPlayer.settingsInfoCategory currentSettingsInfoCategory;
|
||||
|
||||
public void adjustSettingsFromEditor ()
|
||||
{
|
||||
adjustSettings ();
|
||||
}
|
||||
|
||||
public void adjustSettings ()
|
||||
{
|
||||
for (int i = 0; i < settingsInfoCategoryList.Count; i++) {
|
||||
|
||||
currentSettingsInfoCategory = settingsInfoCategoryList [i];
|
||||
|
||||
adjustSettingsFromList (currentSettingsInfoCategory.settingsInfoList);
|
||||
}
|
||||
|
||||
GKC_Utils.updateComponent (mainCustomCharacterControllerBase);
|
||||
}
|
||||
|
||||
public void adjustSettingsFromList (List<buildPlayer.settingsInfo> settingsList)
|
||||
{
|
||||
print ("\n\n");
|
||||
|
||||
print ("Setting list applied to character: \n\n");
|
||||
|
||||
for (int j = 0; j < settingsList.Count; j++) {
|
||||
|
||||
currentSettingsInfo = settingsList [j];
|
||||
|
||||
if (currentSettingsInfo.settingEnabled) {
|
||||
|
||||
if (currentSettingsInfo.useBoolState) {
|
||||
currentSettingsInfo.eventToSetBoolState.Invoke (currentSettingsInfo.boolState);
|
||||
|
||||
if (currentSettingsInfo.eventToSetBoolState.GetPersistentEventCount () > 0) {
|
||||
GKC_Utils.updateComponent (currentSettingsInfo.eventToSetBoolState.GetPersistentTarget (0));
|
||||
}
|
||||
|
||||
print ("Setting " + currentSettingsInfo.Name + " set as " + currentSettingsInfo.useBoolState);
|
||||
}
|
||||
|
||||
if (currentSettingsInfo.useFloatValue) {
|
||||
currentSettingsInfo.eventToSetFloatValue.Invoke (currentSettingsInfo.floatValue);
|
||||
|
||||
if (currentSettingsInfo.eventToSetFloatValue.GetPersistentEventCount () > 0) {
|
||||
GKC_Utils.updateComponent (currentSettingsInfo.eventToSetFloatValue.GetPersistentTarget (0));
|
||||
}
|
||||
|
||||
print ("Setting " + currentSettingsInfo.Name + " set as " + currentSettingsInfo.floatValue);
|
||||
}
|
||||
|
||||
if (currentSettingsInfo.useStringValue) {
|
||||
currentSettingsInfo.eventToSetStringValue.Invoke (currentSettingsInfo.stringValue);
|
||||
|
||||
if (currentSettingsInfo.eventToSetStringValue.GetPersistentEventCount () > 0) {
|
||||
GKC_Utils.updateComponent (currentSettingsInfo.eventToSetStringValue.GetPersistentTarget (0));
|
||||
}
|
||||
|
||||
print ("Setting " + currentSettingsInfo.Name + " set as " + currentSettingsInfo.stringValue);
|
||||
}
|
||||
|
||||
if (currentSettingsInfo.useVector3Value) {
|
||||
currentSettingsInfo.eventToSetVector3Value.Invoke (currentSettingsInfo.vector3Value);
|
||||
|
||||
if (currentSettingsInfo.eventToSetVector3Value.GetPersistentEventCount () > 0) {
|
||||
GKC_Utils.updateComponent (currentSettingsInfo.eventToSetVector3Value.GetPersistentTarget (0));
|
||||
}
|
||||
|
||||
print ("Setting " + currentSettingsInfo.Name + " set as " + currentSettingsInfo.vector3Value);
|
||||
}
|
||||
|
||||
if (currentSettingsInfo.useRegularValue) {
|
||||
if (currentSettingsInfo.regularValue) {
|
||||
currentSettingsInfo.eventToEnableActiveValue.Invoke ();
|
||||
|
||||
if (currentSettingsInfo.eventToEnableActiveValue.GetPersistentEventCount () > 0) {
|
||||
GKC_Utils.updateComponent (currentSettingsInfo.eventToEnableActiveValue.GetPersistentTarget (0));
|
||||
}
|
||||
} else {
|
||||
currentSettingsInfo.eventToDisableActiveValue.Invoke ();
|
||||
|
||||
if (currentSettingsInfo.eventToDisableActiveValue.GetPersistentEventCount () > 0) {
|
||||
GKC_Utils.updateComponent (currentSettingsInfo.eventToDisableActiveValue.GetPersistentTarget (0));
|
||||
}
|
||||
}
|
||||
|
||||
print ("Setting " + currentSettingsInfo.Name + " set as " + currentSettingsInfo.regularValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print ("Character Settings Applied\n\n\n");
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Updated Settings", gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c613971cae792154dae1427b1f88eb10
|
||||
timeCreated: 1653800505
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/customCharacterControllerBaseBuilder.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,888 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class customCharacterControllerManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool startGameWithCustomCharacterController;
|
||||
public string customCharacterControllerToStartName;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool enableNewCustomCharacterIfActiveWhenTogglingToNewOne;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool ignoreSetAIValues;
|
||||
|
||||
public bool setCharacterModeOnRegularState;
|
||||
|
||||
public bool setNewCharacterModeOnRegularState;
|
||||
public string newCharacterModeOnRegularState;
|
||||
|
||||
[Space]
|
||||
[Header ("Character Controller List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<characterControllerStateInfo> characterControllerStateInfoList = new List<characterControllerStateInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool customCharacterControllerActive;
|
||||
|
||||
public string currentCharacterControllerName;
|
||||
|
||||
public bool toggleCustomCharacterControllerPaused;
|
||||
|
||||
public bool genericModelVisibleOnEditor;
|
||||
|
||||
public Avatar originalAvatar;
|
||||
|
||||
public customCharacterControllerBase currentCustomCharacterControllerBase;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnStateChange;
|
||||
|
||||
public UnityEvent eventOnCustomCharacterEnter;
|
||||
public UnityEvent eventOnCustomCharacterExit;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerController mainPlayerController;
|
||||
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
public Animator mainAnimator;
|
||||
|
||||
public RuntimeAnimatorController originalAnimatorController;
|
||||
|
||||
public playerWeaponsManager mainPlayerWeaponManager;
|
||||
|
||||
public playerStatesManager mainPlayerStatesManager;
|
||||
|
||||
public Transform customCharacterControllerParent;
|
||||
|
||||
public CapsuleCollider mainCapsuleCollider;
|
||||
|
||||
public ragdollActivator mainRagdollActivator;
|
||||
public closeCombatSystem mainCloseCombatSystem;
|
||||
|
||||
public otherPowers mainOtherPowersSystem;
|
||||
|
||||
public healthManagement mainHealth;
|
||||
|
||||
public grabObjects mainGrabObjects;
|
||||
|
||||
public AIAbilitiesSystemBrain mainAIAbilitiesSystemBrain;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Components")]
|
||||
[Space]
|
||||
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public AICloseCombatSystemBrain mainAICloseCombatSystemBrain;
|
||||
|
||||
[Space]
|
||||
[Header ("Custom Character Prefab Settings")]
|
||||
[Space]
|
||||
|
||||
public GameObject customCharacterPrefab;
|
||||
|
||||
|
||||
characterControllerStateInfo currentCharacterControllerStateInfo;
|
||||
|
||||
string originalCameraStateThirdPerson;
|
||||
string originalCameraStateFirstPerson;
|
||||
|
||||
string previousCharacterModeName = "";
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (originalAvatar == null) {
|
||||
originalAvatar = mainAnimator.avatar;
|
||||
}
|
||||
|
||||
if (startGameWithCustomCharacterController) {
|
||||
StartCoroutine (startGameWithCustomCharacterControllerCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator startGameWithCustomCharacterControllerCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.2f);
|
||||
|
||||
toggleCustomCharacterController (customCharacterControllerToStartName);
|
||||
}
|
||||
|
||||
public void toggleCustomCharacterControllerExternally (string characterControllerName)
|
||||
{
|
||||
bool previousToggleCustomCharacterControllerPausedValue = toggleCustomCharacterControllerPaused;
|
||||
|
||||
toggleCustomCharacterControllerPaused = false;
|
||||
|
||||
toggleCustomCharacterController (characterControllerName);
|
||||
|
||||
toggleCustomCharacterControllerPaused = previousToggleCustomCharacterControllerPausedValue;
|
||||
}
|
||||
|
||||
public void toggleCustomCharacterController (string characterControllerName)
|
||||
{
|
||||
if (toggleCustomCharacterControllerPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!customCharacterControllerActive) {
|
||||
setCustomCharacterControllerState (characterControllerName);
|
||||
} else {
|
||||
string lastCharacterControllerName = currentCharacterControllerName;
|
||||
|
||||
disableCustomCharacterControllerState ();
|
||||
|
||||
if (enableNewCustomCharacterIfActiveWhenTogglingToNewOne) {
|
||||
if (lastCharacterControllerName != "" && lastCharacterControllerName != characterControllerName) {
|
||||
setCustomCharacterControllerState (characterControllerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disableCustomCharacterControllerState ()
|
||||
{
|
||||
if (!customCharacterControllerActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentCharacterControllerStateInfo != null) {
|
||||
|
||||
currentCharacterControllerStateInfo.isCurrentCharacterController = false;
|
||||
|
||||
currentCharacterControllerStateInfo.eventOnStateEnd.Invoke ();
|
||||
|
||||
if (currentCharacterControllerStateInfo.useEventToSendCharacterObjectOnStateChange) {
|
||||
currentCharacterControllerStateInfo.eventToSendCharacterObjectOnEnd.Invoke (currentCharacterControllerStateInfo.customCharacterController.characterGameObject);
|
||||
}
|
||||
|
||||
setCharacterState (false);
|
||||
|
||||
currentCharacterControllerStateInfo = null;
|
||||
|
||||
currentCharacterControllerName = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setRandomCustomCharacterControllerState ()
|
||||
{
|
||||
int randomIndex = Random.Range (0, characterControllerStateInfoList.Count - 1);
|
||||
|
||||
if (randomIndex <= characterControllerStateInfoList.Count) {
|
||||
setCustomCharacterControllerState (characterControllerStateInfoList [randomIndex].Name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomCharacterControllerState (string characterControllerStateName)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("trying to activate " + characterControllerStateName);
|
||||
}
|
||||
|
||||
if (currentCharacterControllerName == characterControllerStateName) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newCharacterIndex = -1;
|
||||
|
||||
for (int i = 0; i < characterControllerStateInfoList.Count; i++) {
|
||||
if (characterControllerStateInfoList [i].stateEnabled && characterControllerStateInfoList [i].Name.Equals (characterControllerStateName)) {
|
||||
newCharacterIndex = i;
|
||||
} else {
|
||||
if (characterControllerStateInfoList [i].isCurrentCharacterController) {
|
||||
// characterControllerStateInfoList [i].customCharacterController.setCharacterControllerActiveState (false);
|
||||
|
||||
currentCharacterControllerStateInfo = characterControllerStateInfoList [i];
|
||||
|
||||
currentCharacterControllerStateInfo.eventOnStateEnd.Invoke ();
|
||||
|
||||
if (currentCharacterControllerStateInfo.useEventToSendCharacterObjectOnStateChange) {
|
||||
currentCharacterControllerStateInfo.eventToSendCharacterObjectOnEnd.Invoke (currentCharacterControllerStateInfo.customCharacterController.characterGameObject);
|
||||
}
|
||||
|
||||
setCharacterState (false);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("disabling first the character " + currentCharacterControllerStateInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
characterControllerStateInfoList [i].isCurrentCharacterController = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (newCharacterIndex != -1) {
|
||||
|
||||
currentCharacterControllerStateInfo = characterControllerStateInfoList [newCharacterIndex];
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (newCharacterIndex + " " + currentCharacterControllerStateInfo.Name);
|
||||
}
|
||||
|
||||
if (currentCharacterControllerStateInfo.spawnCustomCharacterPrefab) {
|
||||
if (currentCharacterControllerStateInfo.customCharacterInstantiatedObject == null) {
|
||||
instantiateCustomCharacter (currentCharacterControllerStateInfo, false);
|
||||
}
|
||||
}
|
||||
|
||||
currentCharacterControllerStateInfo.isCurrentCharacterController = true;
|
||||
|
||||
currentCharacterControllerName = currentCharacterControllerStateInfo.Name;
|
||||
|
||||
setCharacterState (true);
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print (characterControllerStateName + " not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void instantiateCustomCharacter (characterControllerStateInfo characterInfo, bool instantiatedOnEditorTime)
|
||||
{
|
||||
GameObject customCharacterObject = (GameObject)Instantiate (characterInfo.customCharacterPrefab, Vector3.zero, Quaternion.identity, transform);
|
||||
|
||||
customCharacterObject.name = characterInfo.customCharacterPrefab.name;
|
||||
|
||||
characterInfo.customCharacterInstantiatedObject = customCharacterObject;
|
||||
|
||||
characterInfo.customCharacterController = customCharacterObject.GetComponent<customCharacterControllerBase> ();
|
||||
|
||||
customCharacterObject.transform.localPosition = Vector3.zero;
|
||||
customCharacterObject.transform.localRotation = Quaternion.identity;
|
||||
|
||||
characterInfo.customCharacterController.eventOnInstantiateCustomCharacterObject.Invoke ();
|
||||
|
||||
characterInfo.customCharacterController.mainAnimator = mainAnimator;
|
||||
|
||||
genericRagdollBuilder currentGenericRagdollBuilder = customCharacterObject.GetComponentInChildren<genericRagdollBuilder> ();
|
||||
|
||||
if (currentGenericRagdollBuilder != null) {
|
||||
currentGenericRagdollBuilder.mainRagdollActivator = mainRagdollActivator;
|
||||
|
||||
currentGenericRagdollBuilder.updateRagdollActivatorParts (instantiatedOnEditorTime);
|
||||
}
|
||||
|
||||
followObjectPositionSystem currentFollowObjectPositionSystem = customCharacterObject.GetComponentInChildren<followObjectPositionSystem> ();
|
||||
|
||||
if (currentFollowObjectPositionSystem != null) {
|
||||
currentFollowObjectPositionSystem.setObjectToFollow (mainPlayerController.transform);
|
||||
}
|
||||
|
||||
simpleSliceSystem currentSimpleSliceSystem = customCharacterObject.GetComponentInChildren<simpleSliceSystem> ();
|
||||
|
||||
if (currentSimpleSliceSystem != null) {
|
||||
surfaceToSlice currentSurfaceToSlice = mainPlayerController.GetComponent<surfaceToSlice> ();
|
||||
|
||||
if (currentSurfaceToSlice != null) {
|
||||
currentSurfaceToSlice.mainSimpleSliceSystem = currentSimpleSliceSystem;
|
||||
|
||||
currentSimpleSliceSystem.mainSurfaceToSlice = currentSurfaceToSlice;
|
||||
|
||||
currentSimpleSliceSystem.initializeValuesOnHackableComponent ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setCharacterState (bool state)
|
||||
{
|
||||
currentCustomCharacterControllerBase = currentCharacterControllerStateInfo.customCharacterController;
|
||||
|
||||
currentCustomCharacterControllerBase.setCharacterControllerActiveState (state);
|
||||
|
||||
if (ignoreSetAIValues) {
|
||||
currentCustomCharacterControllerBase.setAIValues = false;
|
||||
}
|
||||
|
||||
bool isFirstPersonActive = mainPlayerCamera.isFirstPersonActive ();
|
||||
|
||||
bool isFullBodyAwarenessActive = mainPlayerCamera.isFullBodyAwarenessActive ();
|
||||
|
||||
if (isFirstPersonActive) {
|
||||
mainPlayerCamera.changeCameraToThirdOrFirstView ();
|
||||
} else {
|
||||
if (isFullBodyAwarenessActive) {
|
||||
mainPlayerCamera.changeCameraToThirdOrFirstView ();
|
||||
}
|
||||
}
|
||||
|
||||
if (state) {
|
||||
mainPlayerController.setCustomCharacterControllerActiveState (true, currentCustomCharacterControllerBase);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.SetParent (customCharacterControllerParent);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.position = mainPlayerController.transform.position +
|
||||
currentCustomCharacterControllerBase.charactetPositionOffset;
|
||||
|
||||
currentCustomCharacterControllerBase.setOriginalCharacterGameObjectTransformPosition (currentCustomCharacterControllerBase.characterGameObject.transform.localPosition);
|
||||
|
||||
currentCustomCharacterControllerBase.setPlayerControllerTransform (mainPlayerController.transform);
|
||||
|
||||
Quaternion targetRotation = Quaternion.Euler (currentCustomCharacterControllerBase.characterRotationOffset);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.localRotation = targetRotation;
|
||||
|
||||
Animator characterAnimator = currentCustomCharacterControllerBase.characterGameObject.GetComponent<Animator> ();
|
||||
|
||||
if (characterAnimator != null && characterAnimator.enabled) {
|
||||
characterAnimator.enabled = false;
|
||||
}
|
||||
|
||||
if (previousCharacterModeName == "") {
|
||||
previousCharacterModeName = mainPlayerStatesManager.getCurrentPlayersModeName ();
|
||||
}
|
||||
|
||||
mainPlayerStatesManager.checkPlayerStates ();
|
||||
|
||||
currentCharacterControllerStateInfo.eventOnStateStart.Invoke ();
|
||||
|
||||
if (currentCharacterControllerStateInfo.useEventToSendCharacterObjectOnStateChange) {
|
||||
currentCharacterControllerStateInfo.eventToSendCharacterObjectOnStart.Invoke (currentCharacterControllerStateInfo.customCharacterController.characterGameObject);
|
||||
}
|
||||
|
||||
mainPlayerStatesManager.setPlayerModeByName (currentCustomCharacterControllerBase.playerModeName);
|
||||
|
||||
mainAnimator.runtimeAnimatorController = currentCustomCharacterControllerBase.originalAnimatorController;
|
||||
mainAnimator.avatar = currentCustomCharacterControllerBase.originalAvatar;
|
||||
|
||||
currentCustomCharacterControllerBase.updateOnGroundValue (mainPlayerController.isPlayerOnGround ());
|
||||
|
||||
if (currentCustomCharacterControllerBase.setCapsuleColliderValues) {
|
||||
mainPlayerController.setPlayerColliderCapsuleScale (currentCustomCharacterControllerBase.capsuleColliderHeight);
|
||||
|
||||
mainPlayerController.setPlayerCapsuleColliderDirection (currentCustomCharacterControllerBase.capsuleColliderDirection);
|
||||
|
||||
mainCapsuleCollider.center = currentCustomCharacterControllerBase.capsuleColliderCenter;
|
||||
|
||||
mainPlayerController.setPlayerCapsuleColliderRadius (currentCustomCharacterControllerBase.capsuleColliderRadius);
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.useExtraColliders) {
|
||||
if (!currentCustomCharacterControllerBase.extraCollidersInfoInitialized) {
|
||||
int extraCollidersListCount = currentCustomCharacterControllerBase.extraCollidersList.Count;
|
||||
|
||||
health mainCharacterHealth = mainHealth as health;
|
||||
|
||||
int characterLayer = mainPlayerController.gameObject.layer;
|
||||
|
||||
for (int i = 0; i < extraCollidersListCount; i++) {
|
||||
Physics.IgnoreCollision (mainCapsuleCollider, currentCustomCharacterControllerBase.extraCollidersList [i], true);
|
||||
|
||||
if (currentCustomCharacterControllerBase.setLayerOnExtraCollider) {
|
||||
currentCustomCharacterControllerBase.extraCollidersList [i].gameObject.layer = characterLayer;
|
||||
}
|
||||
|
||||
characterDamageReceiver currentDamageReceiverToCheck = currentCustomCharacterControllerBase.extraCollidersList [i].GetComponent<characterDamageReceiver> ();
|
||||
|
||||
if (currentDamageReceiverToCheck != null) {
|
||||
currentDamageReceiverToCheck.setCharacter (mainPlayerController.gameObject, mainCharacterHealth);
|
||||
|
||||
mainCharacterHealth.addDamageReceiverGameObjectList (currentDamageReceiverToCheck.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
currentCustomCharacterControllerBase.extraCollidersInfoInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.usePlaceToShootLocalPosition) {
|
||||
mainPlayerController.setPlaceToShootLocalPosition (currentCustomCharacterControllerBase.placeToShootLocalPosition);
|
||||
} else {
|
||||
mainPlayerController.setPlaceToShootPositionOffset (currentCustomCharacterControllerBase.placeToShootOffset);
|
||||
}
|
||||
|
||||
mainPlayerController.setUseRootMotionActiveState (currentCustomCharacterControllerBase.useRootMotion);
|
||||
|
||||
if (!currentCustomCharacterControllerBase.useRootMotion) {
|
||||
mainPlayerController.setNoRootMotionValues (currentCustomCharacterControllerBase.noRootWalkMovementSpeed,
|
||||
currentCustomCharacterControllerBase.noRootRunMovementSpeed, currentCustomCharacterControllerBase.noRootSprintMovementSpeed,
|
||||
currentCustomCharacterControllerBase.noRootCrouchMovementSpeed, currentCustomCharacterControllerBase.noRootCrouchRunMovementSpeed,
|
||||
currentCustomCharacterControllerBase.noRootWalkStrafeMovementSpeed, currentCustomCharacterControllerBase.noRootRunStrafeMovementSpeed);
|
||||
}
|
||||
|
||||
|
||||
mainPlayerController.setCharacterMeshGameObjectState (!state);
|
||||
|
||||
mainPlayerController.setUsingExternalCharacterMeshListState (true);
|
||||
|
||||
mainPlayerController.setExternalCharacterMeshList (currentCustomCharacterControllerBase.characterMeshesList);
|
||||
|
||||
//CAMERA ELEMENTS
|
||||
if (currentCustomCharacterControllerBase.setNewCameraStates && !currentCustomCharacterControllerBase.setAIValues) {
|
||||
originalCameraStateThirdPerson = mainPlayerCamera.getDefaultThirdPersonStateName ();
|
||||
|
||||
originalCameraStateFirstPerson = mainPlayerCamera.getDefaultFirstPersonStateName ();
|
||||
|
||||
if (mainPlayerCamera.isFirstPersonActive ()) {
|
||||
mainPlayerCamera.setCameraStateExternally (currentCustomCharacterControllerBase.newCameraStateFirstPerson);
|
||||
} else {
|
||||
mainPlayerCamera.setCameraStateExternally (currentCustomCharacterControllerBase.newCameraStateThirdPerson);
|
||||
}
|
||||
|
||||
mainPlayerCamera.setDefaultThirdPersonStateName (currentCustomCharacterControllerBase.newCameraStateThirdPerson);
|
||||
|
||||
mainPlayerCamera.setDefaultFirstPersonStateName (currentCustomCharacterControllerBase.newCameraStateFirstPerson);
|
||||
}
|
||||
|
||||
|
||||
//OTHER COMPONENTS FUNCTIONS
|
||||
mainPlayerController.setCurrentCustomActionCategoryID (currentCustomCharacterControllerBase.customActionCategoryID);
|
||||
|
||||
mainPlayerController.setCharacterRadius (currentCustomCharacterControllerBase.characterRadius);
|
||||
|
||||
mainPlayerController.setExtraHeightDiffRaycastRadius (currentCustomCharacterControllerBase.heightDiffRaycastRadius);
|
||||
|
||||
mainPlayerController.setCustomMaxStepHeight (currentCustomCharacterControllerBase.maxStepHeight);
|
||||
|
||||
if (currentCustomCharacterControllerBase.newRayDistance > 0) {
|
||||
mainPlayerController.setNewRayDistance (currentCustomCharacterControllerBase.newRayDistance);
|
||||
}
|
||||
|
||||
mainCloseCombatSystem.setCombatTypeID (currentCustomCharacterControllerBase.combatTypeID);
|
||||
|
||||
if (currentCustomCharacterControllerBase.moveDamageTriggersToMainParentsEnabled) {
|
||||
mainCloseCombatSystem.setNewParentForDamageTriggers (currentCustomCharacterControllerBase.parentForCombatDamageTriggers);
|
||||
}
|
||||
|
||||
mainRagdollActivator.setCurrentRagdollInfo (currentCustomCharacterControllerBase.customRagdollInfoName);
|
||||
|
||||
if (mainOtherPowersSystem != null && currentCustomCharacterControllerBase.otherPowersShootZoneParent != null) {
|
||||
if (state) {
|
||||
mainOtherPowersSystem.setCustomShootZoneParentActiveState (true, currentCustomCharacterControllerBase.otherPowersShootZoneParent);
|
||||
} else {
|
||||
mainOtherPowersSystem.setCustomShootZoneParentActiveState (false, null);
|
||||
}
|
||||
}
|
||||
|
||||
//AI COMPONENTS
|
||||
if (currentCustomCharacterControllerBase.setAIValues) {
|
||||
mainAICloseCombatSystemBrain.setMaxRandomTimeBetweenAttacks (currentCustomCharacterControllerBase.maxRandomTimeBetweenAttacks);
|
||||
mainAICloseCombatSystemBrain.setMinRandomTimeBetweenAttacks (currentCustomCharacterControllerBase.minRandomTimeBetweenAttacks);
|
||||
|
||||
if (currentCustomCharacterControllerBase.minTimeBetweenAttacks > 0) {
|
||||
mainAICloseCombatSystemBrain.setMinTimeBetweenAttacks (currentCustomCharacterControllerBase.minTimeBetweenAttacks);
|
||||
}
|
||||
|
||||
mainAICloseCombatSystemBrain.setBlockEnabledState (false);
|
||||
|
||||
mainFindObjectivesSystem.setNewMinDistanceToEnemyUsingCloseCombat (currentCustomCharacterControllerBase.newMinDistanceToEnemyUsingCloseCombat);
|
||||
|
||||
mainFindObjectivesSystem.setNewMinDistanceToCloseCombat (currentCustomCharacterControllerBase.newMinDistanceToCloseCombat);
|
||||
|
||||
mainFindObjectivesSystem.setCloseCombatAttackMode ();
|
||||
|
||||
mainFindObjectivesSystem.setRayCastPositionOffsetValue (currentCustomCharacterControllerBase.raycastPositionOffset);
|
||||
|
||||
if (currentCustomCharacterControllerBase.healthBarOffset != 0) {
|
||||
mainHealth.updateSliderOffset (currentCustomCharacterControllerBase.healthBarOffset);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCharacterControllerStateInfo.overrideHiddenFromAIAttacksValue) {
|
||||
mainPlayerController.setStealthModeActiveState (currentCharacterControllerStateInfo.hiddenFromAIAttacksValue);
|
||||
} else {
|
||||
if (currentCustomCharacterControllerBase.hiddenFromAIAttacks) {
|
||||
mainPlayerController.setStealthModeActiveState (true);
|
||||
}
|
||||
}
|
||||
|
||||
currentCustomCharacterControllerBase.setCharacterTransform (mainPlayerController.transform);
|
||||
} else {
|
||||
currentCustomCharacterControllerBase.updateOnGroundValue (mainPlayerController.isPlayerOnGround ());
|
||||
|
||||
mainAnimator.runtimeAnimatorController = originalAnimatorController;
|
||||
mainAnimator.avatar = originalAvatar;
|
||||
|
||||
mainPlayerController.setCustomCharacterControllerActiveState (false, null);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.SetParent (null);
|
||||
|
||||
mainPlayerController.setOriginalPlayerColliderCapsuleScale ();
|
||||
|
||||
if (currentCustomCharacterControllerBase.setCapsuleColliderValues) {
|
||||
mainPlayerController.setPlayerCapsuleColliderDirection (1);
|
||||
|
||||
mainPlayerController.setOriginalPlayerCapsuleColliderRadius ();
|
||||
}
|
||||
|
||||
mainPlayerController.setPlaceToShootPositionOffset (-1);
|
||||
|
||||
mainPlayerController.setOriginalUseRootMotionActiveState ();
|
||||
|
||||
mainPlayerController.setOriginalNoRootMotionValues ();
|
||||
|
||||
mainPlayerController.setUsingExternalCharacterMeshListState (false);
|
||||
|
||||
mainPlayerController.setExternalCharacterMeshList (null);
|
||||
|
||||
if (isFirstPersonActive) {
|
||||
currentCustomCharacterControllerBase.enableOrDisableCharacterMeshesList (false);
|
||||
}
|
||||
|
||||
mainPlayerController.setCharacterMeshGameObjectState (!state);
|
||||
|
||||
|
||||
//CAMERA ELEMENTS
|
||||
if (currentCustomCharacterControllerBase.setNewCameraStates && !currentCustomCharacterControllerBase.setAIValues) {
|
||||
if (mainPlayerCamera.isFirstPersonActive ()) {
|
||||
mainPlayerCamera.setCameraStateExternally (originalCameraStateFirstPerson);
|
||||
} else {
|
||||
mainPlayerCamera.setCameraStateExternally (originalCameraStateThirdPerson);
|
||||
}
|
||||
|
||||
mainPlayerCamera.setDefaultThirdPersonStateName (originalCameraStateThirdPerson);
|
||||
|
||||
mainPlayerCamera.setDefaultFirstPersonStateName (originalCameraStateFirstPerson);
|
||||
}
|
||||
|
||||
|
||||
//OTHER COMPONENTS FUNCTIONS
|
||||
mainPlayerController.setCurrentCustomActionCategoryID (0);
|
||||
|
||||
mainPlayerController.setCharacterRadius (0);
|
||||
|
||||
mainPlayerController.setExtraHeightDiffRaycastRadius (0);
|
||||
|
||||
mainPlayerController.setCustomMaxStepHeight (0);
|
||||
|
||||
if (currentCustomCharacterControllerBase.newRayDistance > 0) {
|
||||
mainPlayerController.setOriginalRayDistance ();
|
||||
}
|
||||
|
||||
mainCloseCombatSystem.setCombatTypeID (0);
|
||||
|
||||
if (currentCustomCharacterControllerBase.moveDamageTriggersToMainParentsEnabled) {
|
||||
mainCloseCombatSystem.setOriginalParentForDamageTriggers ();
|
||||
}
|
||||
|
||||
mainRagdollActivator.setCurrentRagdollInfo ("");
|
||||
|
||||
|
||||
//AI COMPONENTS
|
||||
if (currentCustomCharacterControllerBase.setAIValues) {
|
||||
mainAICloseCombatSystemBrain.setOriginalMaxRandomTimeBetweenAttacks ();
|
||||
|
||||
mainAICloseCombatSystemBrain.setOriginalMinRandomTimeBetweenAttacks ();
|
||||
|
||||
mainAICloseCombatSystemBrain.setBlockEnabledState (true);
|
||||
|
||||
mainAICloseCombatSystemBrain.setOriginalMinTimeBetweenAttacks ();
|
||||
|
||||
mainFindObjectivesSystem.setOriginalRayCastPositionOffsetValue ();
|
||||
|
||||
if (currentCustomCharacterControllerBase.healthBarOffset != 0) {
|
||||
mainHealth.updateOriginalSliderOffset ();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.hiddenFromAIAttacks || currentCharacterControllerStateInfo.overrideHiddenFromAIAttacksValue) {
|
||||
mainPlayerController.setStealthModeActiveState (false);
|
||||
}
|
||||
|
||||
currentCustomCharacterControllerBase.setCharacterTransform (null);
|
||||
}
|
||||
|
||||
mainRagdollActivator.setPauseAnimatorStatesToGetUpState (state);
|
||||
|
||||
mainPlayerWeaponManager.enableOrDisableWeaponsMesh (!state);
|
||||
|
||||
mainPlayerController.setCharacterMeshesListToDisableOnEventState (!state);
|
||||
|
||||
mainPlayerController.enableOrDisableIKSystemManagerState (!state);
|
||||
|
||||
mainPlayerController.setFootStepManagerState (state);
|
||||
|
||||
customCharacterControllerActive = state;
|
||||
|
||||
mainPlayerController.setUsingGenericModelActiveState (state);
|
||||
|
||||
mainPlayerCamera.setUsingGenericModelActiveState (state);
|
||||
|
||||
checkEventsOnStateChange (customCharacterControllerActive);
|
||||
|
||||
mainHealth.setIgnoreWeakSpotsActiveState (state);
|
||||
|
||||
if (currentCustomCharacterControllerBase.useExtraColliders) {
|
||||
int extraCollidersListCount = currentCustomCharacterControllerBase.extraCollidersList.Count;
|
||||
|
||||
for (int i = 0; i < extraCollidersListCount; i++) {
|
||||
mainCloseCombatSystem.addOrRemoveObjectToIgnoreByHitTriggers (
|
||||
currentCustomCharacterControllerBase.extraCollidersList [i].gameObject, state);
|
||||
}
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
if (setCharacterModeOnRegularState) {
|
||||
if (previousCharacterModeName != "") {
|
||||
if (setNewCharacterModeOnRegularState) {
|
||||
if (!mainPlayerStatesManager.getCurrentPlayersModeName ().Equals (newCharacterModeOnRegularState)) {
|
||||
mainPlayerStatesManager.setPlayerModeByName (newCharacterModeOnRegularState);
|
||||
}
|
||||
} else {
|
||||
if (!mainPlayerStatesManager.getCurrentPlayersModeName ().Equals (previousCharacterModeName)) {
|
||||
mainPlayerStatesManager.setPlayerModeByName (previousCharacterModeName);
|
||||
}
|
||||
}
|
||||
|
||||
previousCharacterModeName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isFirstPersonActive) {
|
||||
mainPlayerCamera.changeCameraToThirdOrFirstView ();
|
||||
} else {
|
||||
if (isFullBodyAwarenessActive) {
|
||||
mainPlayerCamera.changeCameraToThirdOrFirstView ();
|
||||
}
|
||||
}
|
||||
|
||||
mainPlayerCamera.setHeadColliderStateOnFBA (!state);
|
||||
|
||||
grabObjectGenericModeMountPointSystem currentGrabObjectGenericModeMountPointSystem =
|
||||
currentCustomCharacterControllerBase.GetComponent<grabObjectGenericModeMountPointSystem> ();
|
||||
|
||||
if (currentGrabObjectGenericModeMountPointSystem != null) {
|
||||
if (mainGrabObjects != null) {
|
||||
if (state) {
|
||||
mainGrabObjects.setCurrentGrabObjectGenericModeMountPointSystem (currentGrabObjectGenericModeMountPointSystem);
|
||||
} else {
|
||||
mainGrabObjects.setCurrentGrabObjectGenericModeMountPointSystem (null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.useExtraColliders) {
|
||||
int extraCollidersListCount = currentCustomCharacterControllerBase.extraCollidersList.Count;
|
||||
|
||||
int characterLayer = mainPlayerController.getCharacterLayer ();
|
||||
|
||||
for (int i = 0; i < extraCollidersListCount; i++) {
|
||||
mainPlayerController.addOrRemoveExtraColliders (currentCustomCharacterControllerBase.extraCollidersList [i], state);
|
||||
|
||||
currentCustomCharacterControllerBase.extraCollidersList [i].gameObject.layer = characterLayer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mainAIAbilitiesSystemBrain != null) {
|
||||
if (state) {
|
||||
if (currentCustomCharacterControllerBase.setAbilityBrainAttackEnabledState) {
|
||||
mainAIAbilitiesSystemBrain.setAttackEnabledState (currentCustomCharacterControllerBase.abilityBrainAttackEnabledState);
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.setCustomAbilitiesList) {
|
||||
mainAIAbilitiesSystemBrain.setUseCustomListToChangeAbilityState (true);
|
||||
|
||||
mainAIAbilitiesSystemBrain.setCustomListToChangeAbility (currentCustomCharacterControllerBase.customAbilitiesList);
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.setChangeAbilityAfterTimeEnabledState) {
|
||||
mainAIAbilitiesSystemBrain.setChangeAbilityAfterTimeEnabledState (currentCustomCharacterControllerBase.changeAbilityAfterTimeEnabledState);
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.setAbilityByDefault) {
|
||||
mainAIAbilitiesSystemBrain.setNewAbilityByName (currentCustomCharacterControllerBase.abilityByDefaultName);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.setAIValues) {
|
||||
mainFindObjectivesSystem.getAINavMesh ().updateUseExtraColliderListState ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool isCustomCharacterControllerActive ()
|
||||
{
|
||||
return customCharacterControllerActive;
|
||||
}
|
||||
|
||||
public void checkEventsOnStateChange (bool state)
|
||||
{
|
||||
if (useEventsOnStateChange) {
|
||||
if (state) {
|
||||
eventOnCustomCharacterEnter.Invoke ();
|
||||
} else {
|
||||
eventOnCustomCharacterExit.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setToggleCustomCharacterControllerPausedState (bool state)
|
||||
{
|
||||
toggleCustomCharacterControllerPaused = state;
|
||||
}
|
||||
|
||||
public void addNewCustomCharacterController (customCharacterControllerBase newCustomCharacterControllerBase, string newName)
|
||||
{
|
||||
characterControllerStateInfo newCharacterControllerStateInfo = new characterControllerStateInfo ();
|
||||
|
||||
newCharacterControllerStateInfo.Name = newName;
|
||||
|
||||
newCharacterControllerStateInfo.customCharacterController = newCustomCharacterControllerBase;
|
||||
|
||||
characterControllerStateInfoList.Add (newCharacterControllerStateInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewCustomCharacterControllerToSpawn (GameObject newCustomCharacterControllerBaseObject, string newName)
|
||||
{
|
||||
characterControllerStateInfo newCharacterControllerStateInfo = new characterControllerStateInfo ();
|
||||
|
||||
newCharacterControllerStateInfo.Name = newName;
|
||||
|
||||
newCharacterControllerStateInfo.customCharacterPrefab = newCustomCharacterControllerBaseObject;
|
||||
|
||||
newCharacterControllerStateInfo.spawnCustomCharacterPrefab = true;
|
||||
|
||||
characterControllerStateInfoList.Add (newCharacterControllerStateInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void toggleCharacterModelMeshOnEditor (bool state)
|
||||
{
|
||||
if (genericModelVisibleOnEditor == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
genericModelVisibleOnEditor = state;
|
||||
|
||||
if (currentCustomCharacterControllerBase != null && !genericModelVisibleOnEditor) {
|
||||
currentCustomCharacterControllerBase.setCharacterControllerActiveState (genericModelVisibleOnEditor);
|
||||
|
||||
currentCustomCharacterControllerBase = null;
|
||||
}
|
||||
|
||||
int characterIndex = characterControllerStateInfoList.FindIndex (s => s.Name == customCharacterControllerToStartName);
|
||||
|
||||
if (characterIndex > -1) {
|
||||
currentCharacterControllerStateInfo = characterControllerStateInfoList [characterIndex];
|
||||
|
||||
currentCustomCharacterControllerBase = currentCharacterControllerStateInfo.customCharacterController;
|
||||
|
||||
if (currentCustomCharacterControllerBase == null) {
|
||||
instantiateCustomCharacter (currentCharacterControllerStateInfo, true);
|
||||
|
||||
currentCustomCharacterControllerBase = currentCharacterControllerStateInfo.customCharacterController;
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase != null) {
|
||||
currentCustomCharacterControllerBase.setCharacterControllerActiveState (genericModelVisibleOnEditor);
|
||||
}
|
||||
}
|
||||
|
||||
mainPlayerController.setCharacterMeshGameObjectState (!genericModelVisibleOnEditor);
|
||||
|
||||
mainPlayerWeaponManager.enableOrDisableAllWeaponsMeshes (!genericModelVisibleOnEditor);
|
||||
|
||||
mainPlayerController.setCharacterMeshesListToDisableOnEventState (!genericModelVisibleOnEditor);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setStartGameWithCustomCharacterControllerFromEditor (bool state)
|
||||
{
|
||||
startGameWithCustomCharacterController = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCustomCharacterControllerToStartNameFromEditor (string newCharacterName)
|
||||
{
|
||||
customCharacterControllerToStartName = newCharacterName;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCapsuleValuesFromMainCharacter ()
|
||||
{
|
||||
if (currentCustomCharacterControllerBase != null) {
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderDirectionValue (mainCapsuleCollider.direction);
|
||||
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderCenterValue (mainCapsuleCollider.center);
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderRadiusValue (mainCapsuleCollider.radius);
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderHeightValue (mainCapsuleCollider.height);
|
||||
}
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Add New Custom Character Controller", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class characterControllerStateInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
public bool stateEnabled = true;
|
||||
|
||||
public bool isCurrentCharacterController;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public customCharacterControllerBase customCharacterController;
|
||||
|
||||
[Space]
|
||||
|
||||
[Header ("Spawn Character Ingame Settings")]
|
||||
[Space]
|
||||
|
||||
public bool spawnCustomCharacterPrefab;
|
||||
public GameObject customCharacterPrefab;
|
||||
|
||||
[HideInInspector] public GameObject customCharacterInstantiatedObject;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Visibility")]
|
||||
[Space]
|
||||
|
||||
public bool overrideHiddenFromAIAttacksValue;
|
||||
public bool hiddenFromAIAttacksValue;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnStateStart;
|
||||
public UnityEvent eventOnStateEnd;
|
||||
|
||||
public bool useEventToSendCharacterObjectOnStateChange;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCharacterObjectOnStart;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCharacterObjectOnEnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,703 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class customCharacterControllerManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool startGameWithCustomCharacterController;
|
||||
public string customCharacterControllerToStartName;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public bool ignoreSetAIValues;
|
||||
|
||||
public bool setCharacterModeOnRegularState;
|
||||
|
||||
public bool setNewCharacterModeOnRegularState;
|
||||
public string newCharacterModeOnRegularState;
|
||||
|
||||
[Space]
|
||||
[Header ("Character Controller List Settings")]
|
||||
[Space]
|
||||
|
||||
public List<characterControllerStateInfo> characterControllerStateInfoList = new List<characterControllerStateInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
public bool customCharacterControllerActive;
|
||||
|
||||
public string currentCharacterControllerName;
|
||||
|
||||
public bool toggleCustomCharacterControllerPaused;
|
||||
|
||||
public bool genericModelVisibleOnEditor;
|
||||
|
||||
public Avatar originalAvatar;
|
||||
|
||||
public customCharacterControllerBase currentCustomCharacterControllerBase;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnStateChange;
|
||||
|
||||
public UnityEvent eventOnCustomCharacterEnter;
|
||||
public UnityEvent eventOnCustomCharacterExit;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerController mainPlayerController;
|
||||
|
||||
public playerCamera mainPlayerCamera;
|
||||
|
||||
public Animator mainAnimator;
|
||||
|
||||
public RuntimeAnimatorController originalAnimatorController;
|
||||
|
||||
public playerWeaponsManager mainPlayerWeaponManager;
|
||||
|
||||
public playerStatesManager mainPlayerStatesManager;
|
||||
|
||||
public Transform customCharacterControllerParent;
|
||||
|
||||
public CapsuleCollider mainCapsuleCollider;
|
||||
|
||||
public ragdollActivator mainRagdollActivator;
|
||||
public closeCombatSystem mainCloseCombatSystem;
|
||||
|
||||
public healthManagement mainHealth;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Components")]
|
||||
[Space]
|
||||
|
||||
public findObjectivesSystem mainFindObjectivesSystem;
|
||||
public AICloseCombatSystemBrain mainAICloseCombatSystemBrain;
|
||||
|
||||
[Space]
|
||||
[Header ("Custom Character Prefab Settings")]
|
||||
[Space]
|
||||
|
||||
public GameObject customCharacterPrefab;
|
||||
|
||||
|
||||
characterControllerStateInfo currentCharacterControllerStateInfo;
|
||||
|
||||
string originalCameraStateThirdPerson;
|
||||
string originalCameraStateFirstPerson;
|
||||
|
||||
string previousCharacterModeName = "";
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (originalAvatar == null) {
|
||||
originalAvatar = mainAnimator.avatar;
|
||||
}
|
||||
|
||||
if (startGameWithCustomCharacterController) {
|
||||
StartCoroutine (startGameWithCustomCharacterControllerCoroutine ());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator startGameWithCustomCharacterControllerCoroutine ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.2f);
|
||||
|
||||
toggleCustomCharacterController (customCharacterControllerToStartName);
|
||||
}
|
||||
|
||||
public void toggleCustomCharacterControllerExternally (string characterControllerName)
|
||||
{
|
||||
bool previousToggleCustomCharacterControllerPausedValue = toggleCustomCharacterControllerPaused;
|
||||
|
||||
toggleCustomCharacterControllerPaused = false;
|
||||
|
||||
toggleCustomCharacterController (characterControllerName);
|
||||
|
||||
toggleCustomCharacterControllerPaused = previousToggleCustomCharacterControllerPausedValue;
|
||||
}
|
||||
|
||||
public void toggleCustomCharacterController (string characterControllerName)
|
||||
{
|
||||
if (toggleCustomCharacterControllerPaused) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!customCharacterControllerActive) {
|
||||
setCustomCharacterControllerState (characterControllerName);
|
||||
} else {
|
||||
disableCustomCharacterControllerState ();
|
||||
}
|
||||
}
|
||||
|
||||
public void disableCustomCharacterControllerState ()
|
||||
{
|
||||
if (!customCharacterControllerActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentCharacterControllerStateInfo != null) {
|
||||
|
||||
currentCharacterControllerStateInfo.isCurrentCharacterController = false;
|
||||
|
||||
currentCharacterControllerStateInfo.eventOnStateEnd.Invoke ();
|
||||
|
||||
if (currentCharacterControllerStateInfo.useEventToSendCharacterObjectOnStateChange) {
|
||||
currentCharacterControllerStateInfo.eventToSendCharacterObjectOnEnd.Invoke (currentCharacterControllerStateInfo.customCharacterController.characterGameObject);
|
||||
}
|
||||
|
||||
setCharacterState (false);
|
||||
|
||||
currentCharacterControllerStateInfo = null;
|
||||
|
||||
currentCharacterControllerName = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setRandomCustomCharacterControllerState ()
|
||||
{
|
||||
int randomIndex = Random.Range (0, characterControllerStateInfoList.Count - 1);
|
||||
|
||||
if (randomIndex <= characterControllerStateInfoList.Count) {
|
||||
setCustomCharacterControllerState (characterControllerStateInfoList [randomIndex].Name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCustomCharacterControllerState (string characterControllerStateName)
|
||||
{
|
||||
if (showDebugPrint) {
|
||||
print ("trying to activate " + characterControllerStateName);
|
||||
}
|
||||
|
||||
if (currentCharacterControllerName == characterControllerStateName) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newCharacterIndex = -1;
|
||||
|
||||
for (int i = 0; i < characterControllerStateInfoList.Count; i++) {
|
||||
if (characterControllerStateInfoList [i].stateEnabled && characterControllerStateInfoList [i].Name.Equals (characterControllerStateName)) {
|
||||
newCharacterIndex = i;
|
||||
} else {
|
||||
if (characterControllerStateInfoList [i].isCurrentCharacterController) {
|
||||
// characterControllerStateInfoList [i].customCharacterController.setCharacterControllerActiveState (false);
|
||||
|
||||
currentCharacterControllerStateInfo = characterControllerStateInfoList [i];
|
||||
|
||||
currentCharacterControllerStateInfo.eventOnStateEnd.Invoke ();
|
||||
|
||||
if (currentCharacterControllerStateInfo.useEventToSendCharacterObjectOnStateChange) {
|
||||
currentCharacterControllerStateInfo.eventToSendCharacterObjectOnEnd.Invoke (currentCharacterControllerStateInfo.customCharacterController.characterGameObject);
|
||||
}
|
||||
|
||||
setCharacterState (false);
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("disabling first the character " + currentCharacterControllerStateInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
characterControllerStateInfoList [i].isCurrentCharacterController = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (newCharacterIndex != -1) {
|
||||
|
||||
currentCharacterControllerStateInfo = characterControllerStateInfoList [newCharacterIndex];
|
||||
|
||||
if (showDebugPrint) {
|
||||
print (newCharacterIndex + " " + currentCharacterControllerStateInfo.Name);
|
||||
}
|
||||
|
||||
if (currentCharacterControllerStateInfo.spawnCustomCharacterPrefab) {
|
||||
if (currentCharacterControllerStateInfo.customCharacterInstantiatedObject == null) {
|
||||
instantiateCustomCharacter (currentCharacterControllerStateInfo);
|
||||
}
|
||||
}
|
||||
|
||||
currentCharacterControllerStateInfo.isCurrentCharacterController = true;
|
||||
|
||||
currentCharacterControllerName = currentCharacterControllerStateInfo.Name;
|
||||
|
||||
setCharacterState (true);
|
||||
} else {
|
||||
if (showDebugPrint) {
|
||||
print (characterControllerStateName + " not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void instantiateCustomCharacter (characterControllerStateInfo characterInfo)
|
||||
{
|
||||
GameObject customCharacterObject = (GameObject)Instantiate (characterInfo.customCharacterPrefab, Vector3.zero, Quaternion.identity, transform);
|
||||
|
||||
customCharacterObject.name = characterInfo.customCharacterPrefab.name;
|
||||
|
||||
characterInfo.customCharacterInstantiatedObject = customCharacterObject;
|
||||
|
||||
characterInfo.customCharacterController = customCharacterObject.GetComponent<customCharacterControllerBase> ();
|
||||
|
||||
customCharacterObject.transform.localPosition = Vector3.zero;
|
||||
customCharacterObject.transform.localRotation = Quaternion.identity;
|
||||
|
||||
characterInfo.customCharacterController.eventOnInstantiateCustomCharacterObject.Invoke ();
|
||||
|
||||
characterInfo.customCharacterController.mainAnimator = mainAnimator;
|
||||
|
||||
genericRagdollBuilder currentGenericRagdollBuilder = customCharacterObject.GetComponentInChildren<genericRagdollBuilder> ();
|
||||
|
||||
if (currentGenericRagdollBuilder != null) {
|
||||
currentGenericRagdollBuilder.mainRagdollActivator = mainRagdollActivator;
|
||||
|
||||
currentGenericRagdollBuilder.updateRagdollActivatorPatsIngame ();
|
||||
}
|
||||
|
||||
followObjectPositionSystem currentFollowObjectPositionSystem = customCharacterObject.GetComponentInChildren<followObjectPositionSystem> ();
|
||||
|
||||
if (currentFollowObjectPositionSystem != null) {
|
||||
currentFollowObjectPositionSystem.setObjectToFollow (mainPlayerController.transform);
|
||||
}
|
||||
|
||||
simpleSliceSystem currentSimpleSliceSystem = customCharacterObject.GetComponentInChildren<simpleSliceSystem> ();
|
||||
|
||||
if (currentSimpleSliceSystem != null) {
|
||||
surfaceToSlice currentSurfaceToSlice = mainPlayerController.GetComponent<surfaceToSlice> ();
|
||||
|
||||
if (currentSurfaceToSlice != null) {
|
||||
currentSurfaceToSlice.mainSimpleSliceSystem = currentSimpleSliceSystem;
|
||||
|
||||
currentSimpleSliceSystem.mainSurfaceToSlice = currentSurfaceToSlice;
|
||||
|
||||
currentSimpleSliceSystem.initializeValuesOnHackableComponent ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setCharacterState (bool state)
|
||||
{
|
||||
currentCustomCharacterControllerBase = currentCharacterControllerStateInfo.customCharacterController;
|
||||
|
||||
currentCustomCharacterControllerBase.setCharacterControllerActiveState (state);
|
||||
|
||||
if (ignoreSetAIValues) {
|
||||
currentCustomCharacterControllerBase.setAIValues = false;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
mainPlayerController.setCustomCharacterControllerActiveState (true, currentCustomCharacterControllerBase);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.SetParent (customCharacterControllerParent);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.position = mainPlayerController.transform.position +
|
||||
currentCustomCharacterControllerBase.charactetPositionOffset;
|
||||
|
||||
Quaternion targetRotation = Quaternion.Euler (currentCustomCharacterControllerBase.characterRotationOffset);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.localRotation = targetRotation;
|
||||
|
||||
Animator characterAnimator = currentCustomCharacterControllerBase.characterGameObject.GetComponent<Animator> ();
|
||||
|
||||
if (characterAnimator != null && characterAnimator.enabled) {
|
||||
characterAnimator.enabled = false;
|
||||
}
|
||||
|
||||
if (previousCharacterModeName == "") {
|
||||
previousCharacterModeName = mainPlayerStatesManager.getCurrentPlayersModeName ();
|
||||
}
|
||||
|
||||
mainPlayerStatesManager.checkPlayerStates ();
|
||||
|
||||
currentCharacterControllerStateInfo.eventOnStateStart.Invoke ();
|
||||
|
||||
if (currentCharacterControllerStateInfo.useEventToSendCharacterObjectOnStateChange) {
|
||||
currentCharacterControllerStateInfo.eventToSendCharacterObjectOnStart.Invoke (currentCharacterControllerStateInfo.customCharacterController.characterGameObject);
|
||||
}
|
||||
|
||||
mainPlayerStatesManager.setPlayerModeByName (currentCustomCharacterControllerBase.playerModeName);
|
||||
|
||||
mainAnimator.runtimeAnimatorController = currentCustomCharacterControllerBase.originalAnimatorController;
|
||||
mainAnimator.avatar = currentCustomCharacterControllerBase.originalAvatar;
|
||||
|
||||
currentCustomCharacterControllerBase.updateOnGroundValue (mainPlayerController.isPlayerOnGround ());
|
||||
|
||||
if (currentCustomCharacterControllerBase.setCapsuleColliderValues) {
|
||||
mainPlayerController.setPlayerColliderCapsuleScale (currentCustomCharacterControllerBase.capsuleColliderHeight);
|
||||
|
||||
mainPlayerController.setPlayerCapsuleColliderDirection (currentCustomCharacterControllerBase.capsuleColliderDirection);
|
||||
|
||||
mainCapsuleCollider.center = currentCustomCharacterControllerBase.capsuleColliderCenter;
|
||||
|
||||
mainPlayerController.setPlayerCapsuleColliderRadius (currentCustomCharacterControllerBase.capsuleColliderRadius);
|
||||
}
|
||||
|
||||
mainPlayerController.setPlaceToShootPositionOffset (currentCustomCharacterControllerBase.placeToShootOffset);
|
||||
|
||||
|
||||
mainPlayerController.setUseRootMotionActiveState (currentCustomCharacterControllerBase.useRootMotion);
|
||||
|
||||
if (currentCustomCharacterControllerBase.useRootMotion) {
|
||||
mainPlayerController.setNoRootMotionValues (currentCustomCharacterControllerBase.noRootWalkMovementSpeed,
|
||||
currentCustomCharacterControllerBase.noRootRunMovementSpeed, currentCustomCharacterControllerBase.noRootSprintMovementSpeed,
|
||||
currentCustomCharacterControllerBase.noRootCrouchMovementSpeed,
|
||||
currentCustomCharacterControllerBase.noRootWalkStrafeMovementSpeed, currentCustomCharacterControllerBase.noRootRunStrafeMovementSpeed);
|
||||
}
|
||||
|
||||
|
||||
mainPlayerController.setCharacterMeshGameObjectState (!state);
|
||||
|
||||
mainPlayerController.setUsingExternalCharacterMeshListState (true);
|
||||
|
||||
mainPlayerController.setExternalCharacterMeshList (currentCustomCharacterControllerBase.characterMeshesList);
|
||||
|
||||
//CAMERA ELEMENTS
|
||||
if (currentCustomCharacterControllerBase.setNewCameraStates && !currentCustomCharacterControllerBase.setAIValues) {
|
||||
originalCameraStateThirdPerson = mainPlayerCamera.getDefaultThirdPersonStateName ();
|
||||
|
||||
originalCameraStateFirstPerson = mainPlayerCamera.getDefaultFirstPersonStateName ();
|
||||
|
||||
if (mainPlayerCamera.isFirstPersonActive ()) {
|
||||
mainPlayerCamera.setCameraState (currentCustomCharacterControllerBase.newCameraStateFirstPerson);
|
||||
} else {
|
||||
mainPlayerCamera.setCameraState (currentCustomCharacterControllerBase.newCameraStateThirdPerson);
|
||||
}
|
||||
|
||||
mainPlayerCamera.setDefaultThirdPersonStateName (currentCustomCharacterControllerBase.newCameraStateThirdPerson);
|
||||
|
||||
mainPlayerCamera.setDefaultFirstPersonStateName (currentCustomCharacterControllerBase.newCameraStateFirstPerson);
|
||||
}
|
||||
|
||||
|
||||
//OTHER COMPONENTS FUNCTIONS
|
||||
mainPlayerController.setCurrentCustomActionCategoryID (currentCustomCharacterControllerBase.customActionCategoryID);
|
||||
|
||||
mainPlayerController.setCharacterRadius (currentCustomCharacterControllerBase.characterRadius);
|
||||
|
||||
mainCloseCombatSystem.setCombatTypeID (currentCustomCharacterControllerBase.combatTypeID);
|
||||
|
||||
mainCloseCombatSystem.setNewParentForDamageTriggers (currentCustomCharacterControllerBase.parentForCombatDamageTriggers);
|
||||
|
||||
mainRagdollActivator.setCurrentRagdollInfo (currentCustomCharacterControllerBase.customRagdollInfoName);
|
||||
|
||||
|
||||
//AI COMPONENTS
|
||||
if (currentCustomCharacterControllerBase.setAIValues) {
|
||||
mainAICloseCombatSystemBrain.setMaxRandomTimeBetweenAttacks (currentCustomCharacterControllerBase.maxRandomTimeBetweenAttacks);
|
||||
mainAICloseCombatSystemBrain.setMinRandomTimeBetweenAttacks (currentCustomCharacterControllerBase.minRandomTimeBetweenAttacks);
|
||||
|
||||
mainAICloseCombatSystemBrain.setBlockEnabledState (false);
|
||||
|
||||
mainFindObjectivesSystem.setNewMinDistanceToEnemyUsingCloseCombat (currentCustomCharacterControllerBase.newMinDistanceToEnemyUsingCloseCombat);
|
||||
|
||||
mainFindObjectivesSystem.setNewMinDistanceToCloseCombat (currentCustomCharacterControllerBase.newMinDistanceToCloseCombat);
|
||||
|
||||
mainFindObjectivesSystem.setCloseCombatAttackMode ();
|
||||
|
||||
mainFindObjectivesSystem.setRayCastPositionOffsetValue (currentCustomCharacterControllerBase.raycastPositionOffset);
|
||||
|
||||
if (currentCustomCharacterControllerBase.healthBarOffset != 0) {
|
||||
mainHealth.updateSliderOffset (currentCustomCharacterControllerBase.healthBarOffset);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCharacterControllerStateInfo.overrideHiddenFromAIAttacksValue) {
|
||||
mainPlayerController.setStealthModeActiveState (currentCharacterControllerStateInfo.hiddenFromAIAttacksValue);
|
||||
} else {
|
||||
if (currentCustomCharacterControllerBase.hiddenFromAIAttacks) {
|
||||
mainPlayerController.setStealthModeActiveState (true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
currentCustomCharacterControllerBase.updateOnGroundValue (mainPlayerController.isPlayerOnGround ());
|
||||
|
||||
mainAnimator.runtimeAnimatorController = originalAnimatorController;
|
||||
mainAnimator.avatar = originalAvatar;
|
||||
|
||||
mainPlayerController.setCustomCharacterControllerActiveState (false, null);
|
||||
|
||||
currentCustomCharacterControllerBase.characterGameObject.transform.SetParent (null);
|
||||
|
||||
mainPlayerController.setOriginalPlayerColliderCapsuleScale ();
|
||||
|
||||
if (currentCustomCharacterControllerBase.setCapsuleColliderValues) {
|
||||
mainPlayerController.setPlayerCapsuleColliderDirection (1);
|
||||
|
||||
mainPlayerController.setOriginalPlayerCapsuleColliderRadius ();
|
||||
}
|
||||
|
||||
mainPlayerController.setPlaceToShootPositionOffset (-1);
|
||||
|
||||
mainPlayerController.setOriginalUseRootMotionActiveState ();
|
||||
|
||||
mainPlayerController.setOriginalNoRootMotionValues ();
|
||||
|
||||
mainPlayerController.setUsingExternalCharacterMeshListState (false);
|
||||
|
||||
mainPlayerController.setExternalCharacterMeshList (null);
|
||||
|
||||
mainPlayerController.setCharacterMeshGameObjectState (!state);
|
||||
|
||||
|
||||
//CAMERA ELEMENTS
|
||||
if (currentCustomCharacterControllerBase.setNewCameraStates && !currentCustomCharacterControllerBase.setAIValues) {
|
||||
if (mainPlayerCamera.isFirstPersonActive ()) {
|
||||
mainPlayerCamera.setCameraState (originalCameraStateFirstPerson);
|
||||
} else {
|
||||
mainPlayerCamera.setCameraState (originalCameraStateThirdPerson);
|
||||
}
|
||||
|
||||
mainPlayerCamera.setDefaultThirdPersonStateName (originalCameraStateThirdPerson);
|
||||
|
||||
mainPlayerCamera.setDefaultFirstPersonStateName (originalCameraStateFirstPerson);
|
||||
}
|
||||
|
||||
|
||||
//OTHER COMPONENTS FUNCTIONS
|
||||
mainPlayerController.setCurrentCustomActionCategoryID (0);
|
||||
|
||||
mainPlayerController.setCharacterRadius (0);
|
||||
|
||||
mainCloseCombatSystem.setCombatTypeID (0);
|
||||
|
||||
mainCloseCombatSystem.setOriginalParentForDamageTriggers ();
|
||||
|
||||
mainRagdollActivator.setCurrentRagdollInfo ("");
|
||||
|
||||
|
||||
//AI COMPONENTS
|
||||
if (currentCustomCharacterControllerBase.setAIValues) {
|
||||
mainAICloseCombatSystemBrain.setOriginalMaxRandomTimeBetweenAttacks ();
|
||||
mainAICloseCombatSystemBrain.setOriginalMinRandomTimeBetweenAttacks ();
|
||||
mainAICloseCombatSystemBrain.setBlockEnabledState (true);
|
||||
|
||||
mainFindObjectivesSystem.setOriginalRayCastPositionOffsetValue ();
|
||||
|
||||
if (currentCustomCharacterControllerBase.healthBarOffset != 0) {
|
||||
mainHealth.updateOriginalSliderOffset ();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase.hiddenFromAIAttacks || currentCharacterControllerStateInfo.overrideHiddenFromAIAttacksValue) {
|
||||
mainPlayerController.setStealthModeActiveState (false);
|
||||
}
|
||||
}
|
||||
|
||||
mainRagdollActivator.setPauseAnimatorStatesToGetUpState (state);
|
||||
|
||||
mainPlayerWeaponManager.enableOrDisableWeaponsMesh (!state);
|
||||
|
||||
mainPlayerController.setCharacterMeshesListToDisableOnEventState (!state);
|
||||
|
||||
mainPlayerController.enableOrDisableIKSystemManagerState (!state);
|
||||
|
||||
mainPlayerController.setFootStepManagerState (state);
|
||||
|
||||
customCharacterControllerActive = state;
|
||||
|
||||
mainPlayerController.setUsingGenericModelActiveState (state);
|
||||
|
||||
checkEventsOnStateChange (customCharacterControllerActive);
|
||||
|
||||
if (!state) {
|
||||
if (setCharacterModeOnRegularState) {
|
||||
if (previousCharacterModeName != "") {
|
||||
if (setNewCharacterModeOnRegularState) {
|
||||
if (!mainPlayerStatesManager.getCurrentPlayersModeName ().Equals (newCharacterModeOnRegularState)) {
|
||||
mainPlayerStatesManager.setPlayerModeByName (newCharacterModeOnRegularState);
|
||||
}
|
||||
} else {
|
||||
if (!mainPlayerStatesManager.getCurrentPlayersModeName ().Equals (previousCharacterModeName)) {
|
||||
mainPlayerStatesManager.setPlayerModeByName (previousCharacterModeName);
|
||||
}
|
||||
}
|
||||
|
||||
previousCharacterModeName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool isCustomCharacterControllerActive ()
|
||||
{
|
||||
return customCharacterControllerActive;
|
||||
}
|
||||
|
||||
public void checkEventsOnStateChange (bool state)
|
||||
{
|
||||
if (useEventsOnStateChange) {
|
||||
if (state) {
|
||||
eventOnCustomCharacterEnter.Invoke ();
|
||||
} else {
|
||||
eventOnCustomCharacterExit.Invoke ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setToggleCustomCharacterControllerPausedState (bool state)
|
||||
{
|
||||
toggleCustomCharacterControllerPaused = state;
|
||||
}
|
||||
|
||||
public void addNewCustomCharacterController (customCharacterControllerBase newCustomCharacterControllerBase, string newName)
|
||||
{
|
||||
characterControllerStateInfo newCharacterControllerStateInfo = new characterControllerStateInfo ();
|
||||
|
||||
newCharacterControllerStateInfo.Name = newName;
|
||||
|
||||
newCharacterControllerStateInfo.customCharacterController = newCustomCharacterControllerBase;
|
||||
|
||||
characterControllerStateInfoList.Add (newCharacterControllerStateInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addNewCustomCharacterControllerToSpawn (GameObject newCustomCharacterControllerBaseObject, string newName)
|
||||
{
|
||||
characterControllerStateInfo newCharacterControllerStateInfo = new characterControllerStateInfo ();
|
||||
|
||||
newCharacterControllerStateInfo.Name = newName;
|
||||
|
||||
newCharacterControllerStateInfo.customCharacterPrefab = newCustomCharacterControllerBaseObject;
|
||||
|
||||
newCharacterControllerStateInfo.spawnCustomCharacterPrefab = true;
|
||||
|
||||
characterControllerStateInfoList.Add (newCharacterControllerStateInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void toggleCharacterModelMeshOnEditor (bool state)
|
||||
{
|
||||
if (genericModelVisibleOnEditor == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
genericModelVisibleOnEditor = state;
|
||||
|
||||
if (currentCustomCharacterControllerBase != null && !genericModelVisibleOnEditor) {
|
||||
currentCustomCharacterControllerBase.setCharacterControllerActiveState (genericModelVisibleOnEditor);
|
||||
|
||||
currentCustomCharacterControllerBase = null;
|
||||
}
|
||||
|
||||
int characterIndex = characterControllerStateInfoList.FindIndex (s => s.Name == customCharacterControllerToStartName);
|
||||
|
||||
if (characterIndex > -1) {
|
||||
currentCharacterControllerStateInfo = characterControllerStateInfoList [characterIndex];
|
||||
|
||||
currentCustomCharacterControllerBase = currentCharacterControllerStateInfo.customCharacterController;
|
||||
|
||||
if (currentCustomCharacterControllerBase == null) {
|
||||
instantiateCustomCharacter (currentCharacterControllerStateInfo);
|
||||
|
||||
currentCustomCharacterControllerBase = currentCharacterControllerStateInfo.customCharacterController;
|
||||
}
|
||||
|
||||
if (currentCustomCharacterControllerBase != null) {
|
||||
currentCustomCharacterControllerBase.setCharacterControllerActiveState (genericModelVisibleOnEditor);
|
||||
}
|
||||
}
|
||||
|
||||
mainPlayerController.setCharacterMeshGameObjectState (!genericModelVisibleOnEditor);
|
||||
|
||||
mainPlayerWeaponManager.enableOrDisableAllWeaponsMeshes (!genericModelVisibleOnEditor);
|
||||
|
||||
mainPlayerController.setCharacterMeshesListToDisableOnEventState (!genericModelVisibleOnEditor);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setStartGameWithCustomCharacterControllerFromEditor (bool state)
|
||||
{
|
||||
startGameWithCustomCharacterController = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCustomCharacterControllerToStartNameFromEditor (string newCharacterName)
|
||||
{
|
||||
customCharacterControllerToStartName = newCharacterName;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCapsuleValuesFromMainCharacter ()
|
||||
{
|
||||
if (currentCustomCharacterControllerBase != null) {
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderDirectionValue (mainCapsuleCollider.direction);
|
||||
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderCenterValue (mainCapsuleCollider.center);
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderRadiusValue (mainCapsuleCollider.radius);
|
||||
currentCustomCharacterControllerBase.setCapsuleColliderHeightValue (mainCapsuleCollider.height);
|
||||
}
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Add New Custom Character Controller", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class characterControllerStateInfo
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public string Name;
|
||||
public bool stateEnabled = true;
|
||||
|
||||
public bool isCurrentCharacterController;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
public customCharacterControllerBase customCharacterController;
|
||||
|
||||
[Space]
|
||||
|
||||
[Header ("Spawn Character Ingame Settings")]
|
||||
[Space]
|
||||
|
||||
public bool spawnCustomCharacterPrefab;
|
||||
public GameObject customCharacterPrefab;
|
||||
|
||||
[HideInInspector] public GameObject customCharacterInstantiatedObject;
|
||||
|
||||
[Space]
|
||||
[Header ("AI Visibility")]
|
||||
[Space]
|
||||
|
||||
public bool overrideHiddenFromAIAttacksValue;
|
||||
public bool hiddenFromAIAttacksValue;
|
||||
|
||||
[Space]
|
||||
[Space]
|
||||
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnStateStart;
|
||||
public UnityEvent eventOnStateEnd;
|
||||
|
||||
public bool useEventToSendCharacterObjectOnStateChange;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCharacterObjectOnStart;
|
||||
public eventParameters.eventToCallWithGameObject eventToSendCharacterObjectOnEnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44404130e2b0a4a43a82624e4e55ddad
|
||||
timeCreated: 1658149883
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/customCharacterControllerManager.cs.bak
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42d09584a56828f42bd00fd65cd32a04
|
||||
timeCreated: 1629078574
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/customCharacterControllerManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,267 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class customCharacterControllerSystem : customCharacterControllerBase
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public string horizontalAnimatorName = "Horizontal";
|
||||
public string verticalAnimatorName = "Vertical";
|
||||
public string stateAnimatorName = "State";
|
||||
|
||||
public string groundedStateAnimatorName = "Grounded";
|
||||
public string movementAnimatorName = "Movement";
|
||||
public string speedMultiplierAnimatorName = "SpeedMultiplier";
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public int jumpState = 2;
|
||||
public int movementState = 1;
|
||||
public int fallState = 3;
|
||||
public int deathState = 10;
|
||||
|
||||
[Space]
|
||||
[Header ("Rotation To Surface Settings")]
|
||||
[Space]
|
||||
|
||||
public bool rotateCharacterModelToSurfaceEnabled;
|
||||
|
||||
public float maxCharacterXRotationToSurface = 40;
|
||||
public float maxCharacterZRotationToSurface = 40;
|
||||
|
||||
public float characterRotationToSurfaceSpeed = 10;
|
||||
|
||||
public float characterPositionAdjustmentToSurfaceSpeed = 10;
|
||||
|
||||
public float characterRotationToSurfaceRaycastDistance = 2.5f;
|
||||
|
||||
[Space]
|
||||
|
||||
public float minSurfaceRotation = 5;
|
||||
|
||||
public bool useReverseRotation;
|
||||
|
||||
public bool ignoreLocalZAxisRotationEnabled;
|
||||
|
||||
public bool adjustModelPositionToSurfaceEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public Transform characterPivotTransform;
|
||||
|
||||
public LayerMask surfaceRotationLayermask;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public int currentState;
|
||||
|
||||
public Vector3 targetPosition;
|
||||
|
||||
public bool surfaceFound;
|
||||
|
||||
|
||||
Quaternion targetRotation;
|
||||
|
||||
|
||||
int horizontalAnimatorID;
|
||||
int verticalAnimatorID;
|
||||
|
||||
int stateAnimatorID;
|
||||
int groundedStateAnimatorID;
|
||||
|
||||
int movementAnimatorID;
|
||||
|
||||
bool valuesInitialized;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
bool characterPivotTransformLocated;
|
||||
|
||||
Vector3 originalPivotTransformLocalEuler;
|
||||
|
||||
|
||||
void initializeValues ()
|
||||
{
|
||||
if (!valuesInitialized) {
|
||||
horizontalAnimatorID = Animator.StringToHash (horizontalAnimatorName);
|
||||
verticalAnimatorID = Animator.StringToHash (verticalAnimatorName);
|
||||
|
||||
stateAnimatorID = Animator.StringToHash (stateAnimatorName);
|
||||
groundedStateAnimatorID = Animator.StringToHash (groundedStateAnimatorName);
|
||||
movementAnimatorID = Animator.StringToHash (movementAnimatorName);
|
||||
|
||||
valuesInitialized = true;
|
||||
|
||||
characterPivotTransformLocated = characterPivotTransform != null;
|
||||
|
||||
if (characterPivotTransformLocated) {
|
||||
originalPivotTransformLocalEuler = characterPivotTransform.localEulerAngles;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateCharacterControllerState ()
|
||||
{
|
||||
updateAnimatorFloatValueLerping (horizontalAnimatorID, turnAmount, animatorTurnInputLerpSpeed, Time.fixedDeltaTime);
|
||||
|
||||
updateAnimatorFloatValueLerping (verticalAnimatorID, forwardAmount, animatorForwardInputLerpSpeed, Time.fixedDeltaTime);
|
||||
|
||||
updateAnimatorBoolValue (groundedStateAnimatorID, onGround);
|
||||
|
||||
updateAnimatorBoolValue (movementAnimatorID, playerUsingInput);
|
||||
|
||||
if (canMove && !ragdollCurrentlyActive && rotateCharacterModelToSurfaceEnabled && characterPivotTransformLocated) {
|
||||
updateCharacterRotationToSurface ();
|
||||
}
|
||||
}
|
||||
|
||||
void updateCharacterRotationToSurface ()
|
||||
{
|
||||
Vector3 raycastPosition = playerControllerTransform.position + playerControllerTransform.up;
|
||||
|
||||
Vector3 raycastDirection = -playerControllerTransform.up;
|
||||
|
||||
float hitDistance = 0;
|
||||
|
||||
surfaceFound = false;
|
||||
|
||||
targetRotation = Quaternion.identity;
|
||||
|
||||
targetPosition = originalCharacterPivotTransformPosition;
|
||||
|
||||
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, characterRotationToSurfaceRaycastDistance, surfaceRotationLayermask)) {
|
||||
hitDistance = hit.distance - 1;
|
||||
|
||||
targetPosition.y -= hitDistance;
|
||||
|
||||
surfaceFound = true;
|
||||
}
|
||||
|
||||
if (surfaceFound) {
|
||||
Vector3 surfaceNormal = hit.normal;
|
||||
|
||||
Vector3 forward = playerControllerTransform.forward;
|
||||
|
||||
Vector3 projectedForward = Vector3.ProjectOnPlane (forward, surfaceNormal).normalized;
|
||||
|
||||
Quaternion targetWorldRot = Quaternion.LookRotation (projectedForward, surfaceNormal);
|
||||
|
||||
Quaternion targetLocalRot = Quaternion.Inverse (playerControllerTransform.rotation) * targetWorldRot;
|
||||
|
||||
Vector3 localEuler = targetLocalRot.eulerAngles;
|
||||
|
||||
float x = normalizeAngle (localEuler.x);
|
||||
float z = normalizeAngle (localEuler.z);
|
||||
|
||||
x = Mathf.Clamp (x, -maxCharacterXRotationToSurface, maxCharacterXRotationToSurface);
|
||||
z = Mathf.Clamp (z, -maxCharacterZRotationToSurface, maxCharacterZRotationToSurface);
|
||||
|
||||
if (useReverseRotation) {
|
||||
x = x * (-1);
|
||||
z = z * (-1);
|
||||
}
|
||||
|
||||
if (minSurfaceRotation > 0) {
|
||||
if (Mathf.Abs (x) < minSurfaceRotation && Mathf.Abs (z) < minSurfaceRotation) {
|
||||
x = 0;
|
||||
z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreLocalZAxisRotationEnabled) {
|
||||
targetRotation = Quaternion.Euler (new Vector3 (x, originalPivotTransformLocalEuler.y, 0));
|
||||
} else {
|
||||
targetRotation = Quaternion.Euler (new Vector3 (x, originalPivotTransformLocalEuler.y, z));
|
||||
}
|
||||
} else {
|
||||
targetRotation = Quaternion.Euler (originalPivotTransformLocalEuler);
|
||||
}
|
||||
|
||||
characterPivotTransform.localRotation =
|
||||
Quaternion.Lerp (characterPivotTransform.localRotation, targetRotation, Time.fixedDeltaTime * characterRotationToSurfaceSpeed);
|
||||
|
||||
|
||||
if (adjustModelPositionToSurfaceEnabled) {
|
||||
if (hitDistance != 0 || Mathf.Abs (characterPivotTransform.localPosition.x) > 0.02f) {
|
||||
characterPivotTransform.localPosition =
|
||||
Vector3.Lerp (characterPivotTransform.localPosition, targetPosition, Time.fixedDeltaTime * characterPositionAdjustmentToSurfaceSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//convert angle from 0 to 360 to a range of -180 180 degrees
|
||||
|
||||
float normalizeAngle (float angle)
|
||||
{
|
||||
angle %= 360f;
|
||||
|
||||
if (angle > 180f) {
|
||||
angle -= 360f;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
public override void updateCharacterControllerAnimator ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void updateMovementInputValues (Vector3 newValues)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void updateHorizontalVerticalInputValues (Vector2 newValues)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void activateJumpAnimatorState ()
|
||||
{
|
||||
updateAnimatorIntegerValue (stateAnimatorID, jumpState);
|
||||
|
||||
currentState = jumpState;
|
||||
}
|
||||
|
||||
public override void updateOnGroundValue (bool state)
|
||||
{
|
||||
base.updateOnGroundValue (state);
|
||||
|
||||
if (currentState == 1) {
|
||||
if (!onGround) {
|
||||
updateAnimatorIntegerValue (stateAnimatorID, 3);
|
||||
|
||||
currentState = 3;
|
||||
}
|
||||
} else {
|
||||
if (onGround) {
|
||||
updateAnimatorIntegerValue (stateAnimatorID, 1);
|
||||
|
||||
currentState = 1;
|
||||
} else {
|
||||
|
||||
// if (currentState == 2) {
|
||||
// updateAnimatorIntegerValue (stateAnimatorID, 20);
|
||||
//
|
||||
// currentState = 20;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void setCharacterControllerActiveState (bool state)
|
||||
{
|
||||
base.setCharacterControllerActiveState (state);
|
||||
|
||||
if (state) {
|
||||
initializeValues ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ee90bcc81c11244bb0121b4c93a4f1b
|
||||
timeCreated: 1629077447
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/customCharacterControllerSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class setCustomCharacterStateTriggerSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool triggerEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Generic Character Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setRegularCharacter;
|
||||
|
||||
public string customCharacterNameToConfigure;
|
||||
|
||||
|
||||
public void checkCustomCharacterToActivate (GameObject newCharacterGameObject)
|
||||
{
|
||||
if (!triggerEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newCharacterGameObject == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
playerComponentsManager currentPlayerComponentsManager = newCharacterGameObject.GetComponent<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
customCharacterControllerManager currentCustomCharacterControllerManager = currentPlayerComponentsManager.getCustomCharacterControllerManager ();
|
||||
|
||||
if (currentCustomCharacterControllerManager != null) {
|
||||
if (setRegularCharacter) {
|
||||
if (currentCustomCharacterControllerManager.isCustomCharacterControllerActive ()) {
|
||||
currentCustomCharacterControllerManager.disableCustomCharacterControllerState ();
|
||||
}
|
||||
} else {
|
||||
currentCustomCharacterControllerManager.setCustomCharacterControllerState (customCharacterNameToConfigure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b30ecadb7fa6a0c46b89d514d067757e
|
||||
timeCreated: 1630965843
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/setCustomCharacterStateTriggerSystem.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,132 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class spiderCharacterController : vehicleController
|
||||
{
|
||||
[Space]
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public spiderControllerInterface spider;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool jumpInputActive;
|
||||
|
||||
public bool pauseSpiderInput;
|
||||
|
||||
public override void Start ()
|
||||
{
|
||||
base.Start ();
|
||||
|
||||
if (spider == null) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
base.vehicleUpdate ();
|
||||
|
||||
//Hold down Space to deactivate ground checking. The spider will fall while space is hold.
|
||||
if (pauseSpiderInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
spider.setGroundcheck (!jumpInputActive);
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
if (pauseSpiderInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
//** Movement **//
|
||||
Vector3 input = getInput ();
|
||||
|
||||
if (usingBoost) {
|
||||
spider.run (input);
|
||||
} else {
|
||||
spider.walk (input);
|
||||
}
|
||||
|
||||
Quaternion tempCamTargetRotation = spider.getCamTargetRotation ();
|
||||
Vector3 tempCamTargetPosition = spider.getCamTargetPosition ();
|
||||
|
||||
spider.turn (input);
|
||||
|
||||
spider.setTargetRotation (tempCamTargetRotation);
|
||||
spider.setTargetPosition (tempCamTargetPosition);
|
||||
}
|
||||
|
||||
private Vector3 getInput ()
|
||||
{
|
||||
Vector3 up = spider.transform.up;
|
||||
Vector3 right = spider.transform.right;
|
||||
|
||||
axisValues = getPlayerMovementAxis ();
|
||||
|
||||
Vector3 input = Vector3.ProjectOnPlane (spider.getCameraTarget ().forward, up).normalized * axisValues.y +
|
||||
(Vector3.ProjectOnPlane (spider.getCameraTarget ().right, up).normalized * axisValues.x);
|
||||
|
||||
Quaternion fromTo = Quaternion.AngleAxis (Vector3.SignedAngle (up, spider.getGroundNormal (), right), right);
|
||||
|
||||
input = fromTo * input;
|
||||
float magnitude = input.magnitude;
|
||||
|
||||
return (magnitude <= 1) ? input : input /= magnitude;
|
||||
}
|
||||
|
||||
public void setPauseSpiderInputState (bool state)
|
||||
{
|
||||
pauseSpiderInput = state;
|
||||
}
|
||||
|
||||
//INPUT FUNCTIONS
|
||||
public override void inputHoldOrReleaseJump (bool holdingButton)
|
||||
{
|
||||
if (driving && !usingGravityControl && isTurnedOn) {
|
||||
jumpInputActive = holdingButton;
|
||||
}
|
||||
}
|
||||
|
||||
public override void inputHoldOrReleaseTurbo (bool holdingButton)
|
||||
{
|
||||
if (driving && !usingGravityControl && isTurnedOn) {
|
||||
//boost input
|
||||
if (holdingButton) {
|
||||
if (vehicleControllerSettings.canUseBoost) {
|
||||
usingBoost = true;
|
||||
//set the camera move away action
|
||||
mainVehicleCameraController.usingBoost (true, vehicleControllerSettings.boostCameraShakeStateName,
|
||||
vehicleControllerSettings.useBoostCameraShake, vehicleControllerSettings.moveCameraAwayOnBoost);
|
||||
}
|
||||
} else {
|
||||
//stop boost input
|
||||
usingBoost = false;
|
||||
|
||||
//disable the camera move away action
|
||||
mainVehicleCameraController.usingBoost (false, vehicleControllerSettings.boostCameraShakeStateName,
|
||||
vehicleControllerSettings.useBoostCameraShake, vehicleControllerSettings.moveCameraAwayOnBoost);
|
||||
|
||||
//disable the boost particles
|
||||
usingBoosting ();
|
||||
|
||||
boostInput = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void inputSetTurnOnState ()
|
||||
{
|
||||
if (driving && !usingGravityControl) {
|
||||
if (mainVehicleHUDManager.canSetTurnOnState) {
|
||||
setEngineOnOrOffState ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f94aa5aa8434a76469dc3508832dcf25
|
||||
timeCreated: 1629239049
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/spiderCharacterController.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,445 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class wolfCharacterController : vehicleController
|
||||
{
|
||||
[Header ("Custom Settings")]
|
||||
[Space]
|
||||
|
||||
public customCharacterControllerBase mainCustomCharacterControllerBase;
|
||||
|
||||
public playerController mainPlayerController;
|
||||
|
||||
public Transform vehicleTransform;
|
||||
|
||||
public Transform vehicleCameraTransform;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Options")]
|
||||
[Space]
|
||||
|
||||
public bool rotateCharacterModelToSurfaceEnabled;
|
||||
|
||||
public float maxCharacterXRotationToSurface = 40;
|
||||
public float maxCharacterZRotationToSurface = 40;
|
||||
|
||||
public float characterRotationToSurfaceSpeed = 10;
|
||||
|
||||
public float characterPositionAdjustmentToSurfaceSpeed = 10;
|
||||
|
||||
public float characterRotationToSurfaceRaycastDistance = 2.5f;
|
||||
|
||||
[Space]
|
||||
|
||||
public float minSurfaceRotation = 5;
|
||||
|
||||
public bool useReverseRotation;
|
||||
|
||||
public bool ignoreLocalZAxisRotationEnabled;
|
||||
|
||||
public bool adjustModelPositionToSurfaceEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public Transform characterPivotTransform;
|
||||
|
||||
public LayerMask surfaceRotationLayermask;
|
||||
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public float turnAmount;
|
||||
|
||||
public float forwardAmount;
|
||||
|
||||
public Transform currentCameraPivotTransform;
|
||||
public Transform currentMainCameraTranform;
|
||||
|
||||
public bool useForwardDirectionForCameraDirection;
|
||||
|
||||
public bool useRightDirectionForCameraDirection;
|
||||
|
||||
public bool addExtraRotationPaused;
|
||||
|
||||
|
||||
bool playerUsingInput;
|
||||
|
||||
Vector3 currentMoveInput;
|
||||
|
||||
Vector3 currentForwardDirection;
|
||||
|
||||
Vector3 currentRightDirection;
|
||||
|
||||
|
||||
bool surfaceFound;
|
||||
|
||||
Vector3 targetPosition;
|
||||
|
||||
Quaternion targetRotation;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
bool characterPivotTransformLocated;
|
||||
|
||||
Vector3 originalPivotTransformLocalEuler;
|
||||
|
||||
Vector3 originalCharacterPivotTransformPosition;
|
||||
|
||||
|
||||
public override void Start ()
|
||||
{
|
||||
base.Start ();
|
||||
|
||||
mainPlayerController.setCustomCharacterControllerActiveState (true, mainCustomCharacterControllerBase);
|
||||
|
||||
currentCameraPivotTransform = vehicleCameraTransform;
|
||||
currentMainCameraTranform = vehicleCameraTransform;
|
||||
|
||||
characterPivotTransformLocated = characterPivotTransform != null;
|
||||
|
||||
if (characterPivotTransformLocated) {
|
||||
originalPivotTransformLocalEuler = characterPivotTransform.localEulerAngles;
|
||||
|
||||
originalCharacterPivotTransformPosition = characterPivotTransform.localPosition;
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
base.vehicleUpdate ();
|
||||
}
|
||||
|
||||
void FixedUpdate ()
|
||||
{
|
||||
mainPlayerController.setCustomAxisValues (new Vector2 (horizontalAxis, verticalAxis));
|
||||
|
||||
currentForwardDirection = currentCameraPivotTransform.forward;
|
||||
currentRightDirection = currentMainCameraTranform.right;
|
||||
|
||||
currentMoveInput = verticalAxis * currentForwardDirection + horizontalAxis * currentRightDirection;
|
||||
|
||||
if (currentMoveInput.magnitude > 1) {
|
||||
currentMoveInput.Normalize ();
|
||||
}
|
||||
|
||||
Vector3 localMove = vehicleTransform.InverseTransformDirection (currentMoveInput);
|
||||
|
||||
//get the amount of rotation added to the character mecanim
|
||||
if (currentMoveInput.magnitude > 0) {
|
||||
turnAmount = Mathf.Atan2 (localMove.x, localMove.z);
|
||||
} else {
|
||||
turnAmount = Mathf.Atan2 (0, 0);
|
||||
}
|
||||
|
||||
forwardAmount = localMove.z;
|
||||
|
||||
forwardAmount *= boostInput;
|
||||
|
||||
forwardAmount = Mathf.Clamp (forwardAmount, -boostInput, boostInput);
|
||||
|
||||
|
||||
mainCustomCharacterControllerBase.updateForwardAmountInputValue (forwardAmount);
|
||||
|
||||
if (addExtraRotationPaused && forwardAmount < 0.0001f && verticalAxis < 0) {
|
||||
turnAmount = 0;
|
||||
}
|
||||
|
||||
mainCustomCharacterControllerBase.updateTurnAmountInputValue (turnAmount);
|
||||
|
||||
playerUsingInput = isPlayerUsingInput ();
|
||||
|
||||
mainCustomCharacterControllerBase.updatePlayerUsingInputValue (playerUsingInput);
|
||||
|
||||
mainCustomCharacterControllerBase.updateCharacterControllerAnimator ();
|
||||
|
||||
mainCustomCharacterControllerBase.updateCharacterControllerState ();
|
||||
|
||||
if (rotateCharacterModelToSurfaceEnabled && characterPivotTransformLocated) {
|
||||
updateCharacterRotationToSurface ();
|
||||
}
|
||||
}
|
||||
|
||||
void updateCharacterRotationToSurface ()
|
||||
{
|
||||
Vector3 raycastPosition = vehicleTransform.position + vehicleTransform.up;
|
||||
|
||||
Vector3 raycastDirection = -vehicleTransform.up;
|
||||
|
||||
float hitDistance = 0;
|
||||
|
||||
surfaceFound = false;
|
||||
|
||||
targetRotation = Quaternion.identity;
|
||||
|
||||
targetPosition = originalCharacterPivotTransformPosition;
|
||||
|
||||
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, characterRotationToSurfaceRaycastDistance, surfaceRotationLayermask)) {
|
||||
hitDistance = hit.distance - 1;
|
||||
|
||||
targetPosition.y -= hitDistance;
|
||||
|
||||
surfaceFound = true;
|
||||
}
|
||||
|
||||
if (surfaceFound) {
|
||||
Vector3 surfaceNormal = hit.normal;
|
||||
|
||||
Vector3 forward = vehicleTransform.forward;
|
||||
|
||||
Vector3 projectedForward = Vector3.ProjectOnPlane (forward, surfaceNormal).normalized;
|
||||
|
||||
Quaternion targetWorldRot = Quaternion.LookRotation (projectedForward, surfaceNormal);
|
||||
|
||||
Quaternion targetLocalRot = Quaternion.Inverse (vehicleTransform.rotation) * targetWorldRot;
|
||||
|
||||
Vector3 localEuler = targetLocalRot.eulerAngles;
|
||||
|
||||
float x = normalizeAngle (localEuler.x);
|
||||
float z = normalizeAngle (localEuler.z);
|
||||
|
||||
x = Mathf.Clamp (x, -maxCharacterXRotationToSurface, maxCharacterXRotationToSurface);
|
||||
z = Mathf.Clamp (z, -maxCharacterZRotationToSurface, maxCharacterZRotationToSurface);
|
||||
|
||||
if (useReverseRotation) {
|
||||
x = x * (-1);
|
||||
z = z * (-1);
|
||||
}
|
||||
|
||||
if (minSurfaceRotation > 0) {
|
||||
if (Mathf.Abs (x) < minSurfaceRotation && Mathf.Abs (z) < minSurfaceRotation) {
|
||||
x = 0;
|
||||
z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreLocalZAxisRotationEnabled) {
|
||||
targetRotation = Quaternion.Euler (new Vector3 (x, originalPivotTransformLocalEuler.y, 0));
|
||||
} else {
|
||||
targetRotation = Quaternion.Euler (new Vector3 (x, originalPivotTransformLocalEuler.y, z));
|
||||
}
|
||||
} else {
|
||||
targetRotation = Quaternion.Euler (originalPivotTransformLocalEuler);
|
||||
}
|
||||
|
||||
characterPivotTransform.localRotation = Quaternion.Lerp (characterPivotTransform.localRotation, targetRotation, Time.fixedDeltaTime * characterRotationToSurfaceSpeed);
|
||||
|
||||
if (adjustModelPositionToSurfaceEnabled) {
|
||||
if (hitDistance != 0 || Mathf.Abs (characterPivotTransform.localPosition.x) > 0.02f) {
|
||||
characterPivotTransform.localPosition = Vector3.Lerp (characterPivotTransform.localPosition, targetPosition, Time.fixedDeltaTime * characterPositionAdjustmentToSurfaceSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//convert angle from 0 to 360 to a range of -180 180 degrees
|
||||
|
||||
float normalizeAngle (float angle)
|
||||
{
|
||||
angle %= 360f;
|
||||
|
||||
if (angle > 180f) {
|
||||
angle -= 360f;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
public void setCharacterPivotTransform (Transform newTransform)
|
||||
{
|
||||
characterPivotTransform = newTransform;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void updateMovingState ()
|
||||
{
|
||||
moving = verticalAxis != 0 || horizontalAxis != 0;
|
||||
}
|
||||
|
||||
//if the vehicle is using the gravity control, set the state in this component
|
||||
public override void changeGravityControlUse (bool state)
|
||||
{
|
||||
base.changeGravityControlUse (state);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//the player is getting on or off from the vehicle, so
|
||||
public override void changeVehicleState ()
|
||||
{
|
||||
base.changeVehicleState ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void checkVehicleStateOnPassengerGettingOnOrOff (bool state)
|
||||
{
|
||||
if (state) {
|
||||
if (moveInXAxisOn2_5d) {
|
||||
mainPlayerController.setAddExtraRotationPausedState (true);
|
||||
}
|
||||
} else {
|
||||
if (mainIKDrivingSystem.isVehicleEmpty ()) {
|
||||
mainPlayerController.setAddExtraRotationPausedState (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void setTurnOnState ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void setTurnOffState (bool previouslyTurnedOn)
|
||||
{
|
||||
base.setTurnOffState (previouslyTurnedOn);
|
||||
|
||||
if (previouslyTurnedOn) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isDrivingActive ()
|
||||
{
|
||||
return driving;
|
||||
}
|
||||
|
||||
public override void setEngineOnOrOffState ()
|
||||
{
|
||||
base.setEngineOnOrOffState ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void turnOnOrOff (bool state, bool previouslyTurnedOn)
|
||||
{
|
||||
base.turnOnOrOff (state, previouslyTurnedOn);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//the vehicle has been destroyed, so disabled every component in it
|
||||
public override void disableVehicle ()
|
||||
{
|
||||
base.disableVehicle ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//if the vehicle is using the boost, set the boost particles
|
||||
public override void usingBoosting ()
|
||||
{
|
||||
base.usingBoosting ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void setNewMainCameraTransform (Transform newTransform)
|
||||
{
|
||||
mainPlayerController.setNewMainCameraTransform (newTransform);
|
||||
|
||||
currentMainCameraTranform = newTransform;
|
||||
}
|
||||
|
||||
public override void setNewPlayerCameraTransform (Transform newTransform)
|
||||
{
|
||||
mainPlayerController.setNewPlayerCameraTransform (newTransform);
|
||||
|
||||
currentCameraPivotTransform = newTransform;
|
||||
}
|
||||
|
||||
public override void setUseForwardDirectionForCameraDirectionState (bool state)
|
||||
{
|
||||
// mainPlayerController.setUseForwardDirectionForCameraDirectionState (state);
|
||||
|
||||
useForwardDirectionForCameraDirection = state;
|
||||
|
||||
if (useForwardDirectionForCameraDirection) {
|
||||
currentCameraPivotTransform = vehicleTransform;
|
||||
} else {
|
||||
currentCameraPivotTransform = vehicleCameraTransform;
|
||||
}
|
||||
}
|
||||
|
||||
public override void setUseRightDirectionForCameraDirectionState (bool state)
|
||||
{
|
||||
// mainPlayerController.setUseRightDirectionForCameraDirectionState (state);
|
||||
|
||||
useRightDirectionForCameraDirection = state;
|
||||
|
||||
if (useRightDirectionForCameraDirection) {
|
||||
currentMainCameraTranform = vehicleTransform;
|
||||
} else {
|
||||
currentMainCameraTranform = vehicleCameraTransform;
|
||||
}
|
||||
}
|
||||
|
||||
public override void setAddExtraRotationPausedState (bool state)
|
||||
{
|
||||
mainPlayerController.setAddExtraRotationPausedState (state);
|
||||
|
||||
addExtraRotationPaused = state;
|
||||
}
|
||||
|
||||
//CALL INPUT FUNCTIONS
|
||||
public override void inputJump ()
|
||||
{
|
||||
if (driving && !usingGravityControl && isTurnedOn && vehicleControllerSettings.canJump && mainPlayerController.isPlayerOnGround ()) {
|
||||
|
||||
mainPlayerController.inputJump ();
|
||||
}
|
||||
}
|
||||
|
||||
public override void inputHoldOrReleaseTurbo (bool holdingButton)
|
||||
{
|
||||
if (driving && !usingGravityControl && isTurnedOn) {
|
||||
//boost input
|
||||
if (holdingButton) {
|
||||
if (vehicleControllerSettings.canUseBoost) {
|
||||
if (!usingBoost) {
|
||||
usingBoost = true;
|
||||
|
||||
//set the camera move away action
|
||||
mainVehicleCameraController.usingBoost (true, vehicleControllerSettings.boostCameraShakeStateName,
|
||||
vehicleControllerSettings.useBoostCameraShake, vehicleControllerSettings.moveCameraAwayOnBoost);
|
||||
}
|
||||
|
||||
mainPlayerController.inputStartToRun ();
|
||||
}
|
||||
} else {
|
||||
//stop boost input
|
||||
if (usingBoost) {
|
||||
usingBoost = false;
|
||||
|
||||
//disable the camera move away action
|
||||
mainVehicleCameraController.usingBoost (false, vehicleControllerSettings.boostCameraShakeStateName,
|
||||
vehicleControllerSettings.useBoostCameraShake, vehicleControllerSettings.moveCameraAwayOnBoost);
|
||||
}
|
||||
//disable the boost particles
|
||||
|
||||
usingBoosting ();
|
||||
|
||||
boostInput = 1;
|
||||
|
||||
mainPlayerController.inputStopToRun ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void inputHoldOrReleaseBrake (bool holdingButton)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void inputSetTurnOnState ()
|
||||
{
|
||||
if (driving && !usingGravityControl) {
|
||||
if (mainVehicleHUDManager.canSetTurnOnState) {
|
||||
setEngineOnOrOffState ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30947877d711c094b918a5ff9e6efe38
|
||||
timeCreated: 1629363410
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 40995
|
||||
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
|
||||
packageVersion: 3.77g
|
||||
assetPath: Assets/Game Kit Controller/Scripts/Player/Generic Model Controller/wolfCharacterController.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user