plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,705 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class bulletTimeFiringSystem : OnAnimatorIKComponent
{
[Header ("Main Settings")]
[Space]
public bool movementEnabled = true;
public float lookDirectionForwardOffset = 1000;
public float timeForRaisingHands = 0.5f;
public bool onlyActiveIfUsingFireWeapons;
public float bodyWeightLerpSpeed = 1;
[Space]
[Header ("Get Up Settings")]
[Space]
public bool getUpAfterDelayOnGround;
public float delayToGetUpOnGround;
public float minWaitToCheckOnGroundState;
[Space]
[Header ("Weapons Settings")]
[Space]
public bool keepWeaponsDuringAction;
public bool drawWeaponsAfterAction;
public bool useOnlyWhenUsingFireWeapons;
[Space]
[Header ("Time Bullet Settings")]
[Space]
public bool useTimeBullet;
public float timeBulletScale = 0.5f;
public bool useTimeBulletDuration;
public float timeBulletDuration;
public bool useEventsOnTimeBullet;
public UnityEvent eventOnTimeBulletStart;
public UnityEvent eventOnTimeBulletEnd;
[Space]
[Header ("Physics Settings")]
[Space]
public float jumpForce;
public float pushForce;
public float extraSpeedOnFall;
public float addExtraSpeedOnFallDuration;
public float delayToAddExtraSpeedOnFall;
[Space]
[Header ("Third Person Settings")]
[Space]
public int actionID = 323565;
public int actionIDWithRoll = 323566;
public bool startActionWithRoll;
public float rollOnStartDuration;
public string externalControlleBehaviorActiveAnimatorName = "External Behavior Active";
public string actionIDAnimatorName = "Action ID";
public string horizontalAnimatorName = "Horizontal Action";
public string verticalAnimatorName = "Vertical Action";
public float delayToResumeAfterGetUp = 1;
[Space]
[Header ("Third Person Camera State Settings")]
[Space]
public bool setNewCameraStateOnThirdPerson;
public string newCameraStateOnThirdPerson;
[Space]
[Header ("Action System Settings")]
[Space]
public int customActionCategoryID = -1;
public int regularActionCategoryID = -1;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool movementActive;
public bool armsIKActive;
public float currentTimeForRisingHands;
public float currentArmsWeight;
public float armsWeight = 1;
public bool playerIsCarryingWeapons;
public Vector3 lookDirectionTarget;
public bool groundDetectedAfterJump;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnStart;
public UnityEvent eventOnEnd;
public UnityEvent eventOnGetUpForward;
public UnityEvent eventOnGetUpBackward;
public UnityEvent eventOnGetUpRight;
public UnityEvent eventOnGetUpLeft;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public playerCamera mainPlayerCamera;
public playerInputManager playerInput;
public timeBullet mainTimeBullet;
public Animator mainAnimator;
public Camera mainCamera;
public Transform mainCameraTransform;
public playerWeaponsManager mainPlayerWeaponsManager;
public headTrack mainHeadTrack;
public Transform playerTransform;
Vector3 lookDirection;
Vector2 mouseAxisValues;
Vector3 leftArmAimPosition;
Vector3 rightArmAimPosition;
int externalControlleBehaviorActiveAnimatorID;
int actionIDAnimatorID;
int horizontalAnimatorID;
int verticalAnimatorID;
bool activateGetUp;
float lastTimeGetup;
string previousCameraState;
float bodyWeight;
Vector3 lastJumpDirection;
bool timeBulletActive;
bool carryingWeaponsPreviously;
float lastTimeMovementActive;
void Start ()
{
externalControlleBehaviorActiveAnimatorID = Animator.StringToHash (externalControlleBehaviorActiveAnimatorName);
actionIDAnimatorID = Animator.StringToHash (actionIDAnimatorName);
horizontalAnimatorID = Animator.StringToHash (horizontalAnimatorName);
verticalAnimatorID = Animator.StringToHash (verticalAnimatorName);
}
void Update ()
{
if (movementActive) {
if (!activateGetUp) {
lookDirectionTarget = mainCameraTransform.position + mainCameraTransform.forward * lookDirectionForwardOffset;
}
}
}
void FixedUpdate ()
{
if (movementActive) {
if (activateGetUp) {
if (Time.unscaledTime > delayToResumeAfterGetUp + lastTimeGetup) {
disableMovement ();
}
} else {
Vector3 aimDirection = mainCameraTransform.forward;
aimDirection.y = 0f;
aimDirection = aimDirection.normalized;
aimDirection = playerTransform.InverseTransformDirection (aimDirection);
mainAnimator.SetFloat (horizontalAnimatorID, aimDirection.x);
mainAnimator.SetFloat (verticalAnimatorID, aimDirection.z);
if (mainPlayerController.isPlayerOnGround ()) {
if (Time.unscaledTime > minWaitToCheckOnGroundState + lastTimeMovementActive) {
groundDetectedAfterJump = true;
}
}
if (!jumpCoroutineActive) {
if (extraSpeedOnFall > 0) {
if (Time.unscaledTime > lastTimeMovementActive + delayToAddExtraSpeedOnFall) {
if (Time.unscaledTime < addExtraSpeedOnFallDuration + lastTimeMovementActive) {
if (!groundDetectedAfterJump) {
mainPlayerController.addExternalForce (lastJumpDirection * extraSpeedOnFall);
}
}
}
}
if (getUpAfterDelayOnGround && groundDetectedAfterJump) {
if (Time.unscaledTime > lastTimeMovementActive + delayToGetUpOnGround) {
setMovementActiveState (false);
}
}
}
if (useEventsOnTimeBullet && timeBulletActive) {
if (Time.unscaledTime > lastTimeMovementActive + timeBulletDuration) {
// print (Time.unscaledTime + " " + (lastTimeMovementActive + timeBulletDuration));
checkTimeBullet (false);
}
}
}
}
}
public void setMovementActiveState (bool state)
{
if (!movementEnabled) {
return;
}
if (movementActive == state) {
return;
}
if (state) {
movementActive = state;
mainPlayerController.setIgnoreUseDelayOnGroundJumpActiveState (true);
lastTimeMovementActive = Time.unscaledTime;
if (startActionWithRoll) {
stopActivateJumpForcesCoroutine ();
activateJumpCoroutine = StartCoroutine (activateJumpForcesCoroutine ());
} else {
activateJumpForces ();
}
setPlayerState (true);
checkTimeBullet (true);
} else {
bool lookingForward = false;
Vector3 movementDirection = playerTransform.forward;
if (playerInput.getPlayerMovementAxis () != Vector2.zero) {
movementDirection = mainPlayerController.getMoveInputDirection ();
}
float angle = Vector3.SignedAngle (movementDirection, mainCameraTransform.forward, playerTransform.up);
float ABSAngle = Mathf.Abs (angle);
if (ABSAngle < 160) {
lookingForward = true;
}
if (showDebugPrint) {
print ("looking in forward direction " + lookingForward + " " + ABSAngle);
}
activateGetUp = true;
lastTimeGetup = Time.unscaledTime;
mainAnimator.SetBool (externalControlleBehaviorActiveAnimatorID, false);
mainAnimator.SetInteger (actionIDAnimatorID, 0);
if (lookingForward) {
if (ABSAngle < 45) {
eventOnGetUpForward.Invoke ();
} else if (angle < 0) {
eventOnGetUpRight.Invoke ();
if (showDebugPrint) {
print ("activating event on right");
}
} else {
eventOnGetUpLeft.Invoke ();
if (showDebugPrint) {
print ("activating event on left");
}
}
} else {
eventOnGetUpBackward.Invoke ();
}
checkTimeBullet (false);
lastJumpDirection = Vector3.zero;
}
groundDetectedAfterJump = false;
//desactivar el salto y demas acciones que no se puedan hacer, quizas algunas cosas de las armas
//opciones de usar con y sin armas, quizas para algun tipo de dash o esquive
}
void activateJumpForces ()
{
setUpdateIKEnabledState (true);
Vector2 movementDirection = playerInput.getPlayerMovementAxis ();
Vector3 forceDirection = new Vector3 (movementDirection.x, 0, movementDirection.y);
if (playerInput.getAuxRawMovementAxis () == Vector2.zero) {
forceDirection = playerTransform.forward;
}
lastJumpDirection = forceDirection;
Vector3 jumpDirection = pushForce * forceDirection;
jumpDirection += playerTransform.up * jumpForce;
mainPlayerController.useJumpPlatform (jumpDirection, ForceMode.Impulse);
}
bool jumpCoroutineActive;
Coroutine activateJumpCoroutine;
public void stopActivateJumpForcesCoroutine ()
{
if (activateJumpCoroutine != null) {
StopCoroutine (activateJumpCoroutine);
}
jumpCoroutineActive = false;
}
IEnumerator activateJumpForcesCoroutine ()
{
jumpCoroutineActive = true;
yield return new WaitForSeconds (rollOnStartDuration);
jumpCoroutineActive = false;
activateJumpForces ();
}
void checkTimeBullet (bool state)
{
if (useTimeBullet) {
if (state) {
if (!timeBulletActive) {
if (mainTimeBullet.isTimeBulletActivated ()) {
mainTimeBullet.updateTimeBulletTime (timeBulletScale);
mainTimeBullet.updateTimeScaleValue ();
} else {
mainTimeBullet.setNewTimeBulletTimeSpeedValue (timeBulletScale);
mainTimeBullet.activateTime ();
}
timeBulletActive = true;
if (useEventsOnTimeBullet) {
eventOnTimeBulletStart.Invoke ();
}
}
} else {
if (timeBulletActive) {
if (mainTimeBullet.isTimeBulletActivated ()) {
mainTimeBullet.setOriginalTimeBulletTimeSpeed ();
mainTimeBullet.activateTime ();
}
timeBulletActive = false;
if (useEventsOnTimeBullet) {
eventOnTimeBulletEnd.Invoke ();
}
}
}
}
}
public void disableMovement ()
{
if (movementActive) {
stopActivateJumpForcesCoroutine ();
movementActive = false;
activateGetUp = false;
setPlayerState (false);
}
}
void setPlayerState (bool state)
{
bool isFirstPersonActive = mainPlayerController.isPlayerOnFirstPerson ();
if (state) {
if (startActionWithRoll) {
mainAnimator.SetInteger (actionIDAnimatorID, actionIDWithRoll);
} else {
mainAnimator.SetInteger (actionIDAnimatorID, actionID);
}
mainAnimator.SetBool (externalControlleBehaviorActiveAnimatorID, state);
if (setNewCameraStateOnThirdPerson && !isFirstPersonActive) {
previousCameraState = mainPlayerCamera.getCurrentStateName ();
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (newCameraStateOnThirdPerson);
}
carryingWeaponsPreviously = mainPlayerWeaponsManager.isPlayerCarringWeapon ();
if (carryingWeaponsPreviously) {
if (keepWeaponsDuringAction) {
mainPlayerWeaponsManager.checkIfDisableCurrentWeapon ();
mainPlayerWeaponsManager.resetWeaponHandIKWeight ();
} else {
mainPlayerWeaponsManager.stopShootingFireWeaponIfActive ();
mainPlayerWeaponsManager.enableOrDisableIKOnWeaponsDuringAction (false);
}
}
} else {
mainAnimator.SetBool (externalControlleBehaviorActiveAnimatorID, false);
mainAnimator.SetInteger (actionIDAnimatorID, 0);
if (setNewCameraStateOnThirdPerson && !isFirstPersonActive) {
if (previousCameraState != "") {
if (previousCameraState != newCameraStateOnThirdPerson) {
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (previousCameraState);
}
previousCameraState = "";
}
}
if (carryingWeaponsPreviously) {
if (drawWeaponsAfterAction) {
mainPlayerWeaponsManager.checkIfDrawSingleOrDualWeapon ();
} else {
if (mainPlayerWeaponsManager.isAimingWeapons ()) {
mainPlayerWeaponsManager.setPauseUpperBodyRotationSystemActiveState (false);
}
mainPlayerWeaponsManager.enableOrDisableIKOnWeaponsDuringAction (true);
}
carryingWeaponsPreviously = false;
}
checkTimeBullet (false);
mainPlayerController.setIgnoreUseDelayOnGroundJumpActiveState (false);
}
setCurrentPlayerActionSystemCustomActionCategoryID ();
setUpdateIKEnabledState (state);
mainPlayerController.setIgnoreExternalActionsActiveState (state);
mainPlayerController.setAddExtraRotationPausedState (state);
mainHeadTrack.setHeadTrackSmoothPauseState (state);
mainPlayerController.setUseExternalControllerBehaviorPausedState (state);
mainPlayerWeaponsManager.setPauseUpperBodyRotationSystemActiveState (state);
mainPlayerWeaponsManager.setPauseRecoilOnWeaponActiveState (state);
mainPlayerWeaponsManager.setPauseWeaponReloadActiveState (state);
mainPlayerWeaponsManager.setPauseWeaponAimMovementActiveState (state);
mainPlayerController.setIgnoreLookInCameraDirectionOnFreeFireActiveState (state);
checkEventOnStateChange (state);
mainPlayerController.setFootStepManagerState (state);
mainPlayerController.setIgnoreInputOnAirControlActiveState (state);
mainPlayerController.setPlayerActionsInputEnabledState (!state);
}
public void resetActionIdOnTimeBulletJump ()
{
mainAnimator.SetInteger (actionIDAnimatorID, 0);
}
public override void updateOnAnimatorIKState ()
{
if (!updateIKEnabled) {
return;
}
mainAnimator.SetLookAtPosition (lookDirectionTarget);
mainAnimator.SetLookAtWeight (bodyWeight, 0.5f, 1.0f, 1.0f, 0.7f);
if (activateGetUp || jumpCoroutineActive) {
bodyWeight = Mathf.Lerp (0, bodyWeight, currentTimeForRisingHands / bodyWeightLerpSpeed);
} else {
bodyWeight = Mathf.Lerp (1, bodyWeight, currentTimeForRisingHands / bodyWeightLerpSpeed);
}
if (activateGetUp || jumpCoroutineActive) {
if (!armsIKActive) {
return;
}
if (currentTimeForRisingHands > 0) {
currentTimeForRisingHands -= Time.unscaledDeltaTime;
currentArmsWeight = Mathf.Lerp (0, armsWeight, currentTimeForRisingHands / timeForRaisingHands);
} else {
currentTimeForRisingHands = 0;
currentArmsWeight = 0;
armsIKActive = false;
}
} else {
armsIKActive = true;
if (currentTimeForRisingHands < timeForRaisingHands) {
currentTimeForRisingHands += Time.unscaledDeltaTime;
currentArmsWeight = Mathf.Lerp (0, armsWeight, currentTimeForRisingHands / timeForRaisingHands);
} else {
currentTimeForRisingHands = timeForRaisingHands;
currentArmsWeight = armsWeight;
}
}
}
public void setCurrentPlayerActionSystemCustomActionCategoryID ()
{
if (movementActive) {
if (customActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (customActionCategoryID);
}
} else {
if (regularActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (regularActionCategoryID);
}
}
}
void checkIfSetBulletTimeFiringState ()
{
if (movementEnabled) {
if (activateGetUp) {
return;
}
if (mainPlayerController.iscloseCombatAttackInProcess ()) {
return;
}
if (useOnlyWhenUsingFireWeapons) {
if (!mainPlayerController.isPlayerUsingWeapons () ||
mainPlayerWeaponsManager.weaponsAreMoving () ||
mainPlayerWeaponsManager.currentWeaponIsMoving ()) {
return;
}
}
if (mainPlayerController.isExternalControllBehaviorActive ()) {
return;
}
if (mainPlayerController.isActionActive ()) {
return;
}
if (mainPlayerController.playerIsBusy ()) {
return;
}
if (!mainPlayerController.canPlayerMove ()) {
return;
}
playerIsCarryingWeapons = mainPlayerController.isPlayerUsingWeapons ();
if (onlyActiveIfUsingFireWeapons) {
if (!playerIsCarryingWeapons) {
return;
}
}
if (movementActive) {
if (mainPlayerController.isPlayerOnGround ()) {
setMovementActiveState (false);
} else {
disableMovement ();
}
} else {
if (!mainPlayerController.isPlayerOnGround ()) {
return;
}
setMovementActiveState (true);
}
}
}
public void inputSetTimeBullettFiring ()
{
checkIfSetBulletTimeFiringState ();
}
public void checkEventOnStateChange (bool state)
{
if (state) {
eventOnStart.Invoke ();
} else {
eventOnEnd.Invoke ();
}
}
public void setMovementEnabledState (bool state)
{
movementEnabled = state;
}
//EDITOR FUNCTIONS
public void setMovementEnabledStateFromEditor (bool state)
{
setMovementEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Bullet Time Firing System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 561cb443837fec1478d234c5af802460
timeCreated: 1642467817
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/Extra Movements/bulletTimeFiringSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,742 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class climbDetectionCollisionSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
[SerializeField, Range (0f, 100f)]
float maxSpeed = 10f;
[SerializeField, Range (0f, 100f)]
float maxVerticalClimbSpeed = 4f;
[SerializeField, Range (0f, 100f)]
float maxHorizontalClimbSpeed = 4;
[SerializeField, Range (0f, 100f)]
float maxDiagonalUpClimbSpeed = 4;
[SerializeField, Range (0f, 100f)]
float maxDiagonalDownClimbSpeed = 4;
[SerializeField, Range (0f, 100f)]
float maxSlideDownClimbSpeed = 6;
[SerializeField, Range (0f, 100f)]
float maxBoostClimbSpeedMultiplier = 1.5f;
[Space]
[SerializeField, Range (0f, 100f)]
float maxAcceleration = 10f;
[SerializeField, Range (0f, 100f)]
float maxAirAcceleration = 1f;
[SerializeField, Range (0f, 100f)]
float maxClimbAcceleration = 40f;
[SerializeField, Range (0, 90)]
float maxGroundAngle = 25f, maxStairsAngle = 50f;
[SerializeField, Range (90, 170)]
float maxClimbAngle = 140f;
[SerializeField, Range (0f, 100f)]
float maxSnapSpeed = 100f;
[Space]
[SerializeField]
float probeDistance = 1f;
[SerializeField]
LayerMask probeMask = -1, stairsMask = -1, climbMask = -1;
[SerializeField]
float sphereRadius = 0.5f;
[SerializeField]
float sphereAlignSpeed = 45;
[SerializeField]
float sphereAirRotation = 0.5f;
[Space]
[Header ("Curve Speed Settings")]
[Space]
public bool useCurveSpeedEnabled = true;
public float horizontalCurveSpeed = 0.1f;
public float verticalCurveSpeed = 0.1f;
public float diagonalUpCurveSpeed = 0.1f;
public float diagonalDownCurveSpeed = 0.1f;
[Space]
public AnimationCurve climbSpeedCurve;
public AnimationCurve climbBoostSpeedCurve;
[Space]
[Header ("Debug")]
[Space]
public bool anyOnGround;
public int climbContactCount;
public int groundContactCount;
public int steepContactCount;
public int stepsSinceLastGrounded;
public bool climbDetectionActive;
[Space]
public Vector3 velocity;
public Vector3 contactNormal;
public Vector3 climbNormal;
public Vector3 steepNormal;
public Vector3 lastClimbNormal;
public float currentCurveValue = 0;
[Space]
[Header ("Movement Debug")]
[Space]
public bool movingHorizontal;
public bool movingVertical;
public bool movingDiagonalUp;
public bool movingDiagonalDown;
[Space]
[Header ("Components")]
[Space]
public freeClimbSystem mainFreeClimbSystem;
public Rigidbody mainRigidbody;
public Transform mainCameraTransform;
public Collider mainCollider;
public Collider mainPlayerCollider;
public Transform sphereTransform;
Vector3 moveInput;
Rigidbody connectedBody;
Rigidbody previousConnectedBody;
Vector3 connectionVelocity;
Vector3 connectionWorldPosition;
Vector3 connectionLocalPosition;
Vector3 upAxis, rightAxis, forwardAxis;
Vector3 lastContactNormal;
Vector3 lastSteepNormal;
Vector3 lastConnectionVelocity;
float minGroundDotProduct, minStairsDotProduct, minClimbDotProduct;
Coroutine updateCoroutine;
float currentCurveSpeed = 0;
public void updateObjectPosition (Vector3 newPosition)
{
transform.position = newPosition;
}
public void enableOrDisableClimbDetection (bool state)
{
climbDetectionActive = state;
groundContactCount = 1;
mainRigidbody.isKinematic = !state;
mainCollider.enabled = state;
if (climbDetectionActive) {
minGroundDotProduct = Mathf.Cos (maxGroundAngle * Mathf.Deg2Rad);
minStairsDotProduct = Mathf.Cos (maxStairsAngle * Mathf.Deg2Rad);
minClimbDotProduct = Mathf.Cos (maxClimbAngle * Mathf.Deg2Rad);
Physics.IgnoreCollision (mainCollider, mainPlayerCollider, true);
mainFreeClimbSystem.mainPlayerController.setIgnoreCollisionOnExternalColliderOnlyWithExtraColliderList (mainCollider, true);
Vector3 climbPosition = mainPlayerCollider.transform.position;
Vector3 climbDetectionCollisionPositionOffset = mainFreeClimbSystem.climbDetectionCollisionPositionOffset;
if (climbDetectionCollisionPositionOffset != Vector3.zero) {
climbPosition += mainPlayerCollider.transform.right * climbDetectionCollisionPositionOffset.x;
climbPosition += mainPlayerCollider.transform.up * climbDetectionCollisionPositionOffset.y;
climbPosition += mainPlayerCollider.transform.forward * climbDetectionCollisionPositionOffset.z;
}
transform.position = climbPosition;
} else {
}
mainPlayerCollider.isTrigger = state;
if (climbDetectionActive) {
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
} else {
stopUpdateCoroutine ();
}
}
public void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
moveInput.x = mainFreeClimbSystem.currentHorizontalMovement;
moveInput.z = mainFreeClimbSystem.currentVerticalMovement;
moveInput.y = 0;
moveInput = Vector3.ClampMagnitude (moveInput, 1f);
rightAxis = projectDirectionOnPlane (mainCameraTransform.right, upAxis);
forwardAxis = projectDirectionOnPlane (mainCameraTransform.forward, upAxis);
movingHorizontal = false;
movingVertical = false;
movingDiagonalUp = false;
movingDiagonalDown = false;
if (moveInput.x != 0) {
movingHorizontal = true;
}
if (moveInput.z != 0) {
movingVertical = true;
}
if (movingHorizontal && movingVertical) {
if (moveInput.z < 0) {
movingDiagonalUp = false;
movingDiagonalDown = true;
} else {
movingDiagonalUp = true;
movingDiagonalDown = false;
}
}
updateSphereState ();
}
void FixedUpdate ()
{
if (climbDetectionActive) {
anyOnGround = isOnGround ();
upAxis = mainFreeClimbSystem.getCurrentNormal ();
Vector3 gravity = -upAxis;
//* mainVehicleGravityControl.getGravityForce ();
fixedUpdateSphereState ();
adjustVelocity ();
if (climbSurfaceDetected ()) {
velocity -= contactNormal * (maxClimbAcceleration * 0.9f * Time.deltaTime);
} else if (isOnGround () && velocity.sqrMagnitude < 0.01f) {
velocity += contactNormal * (Vector3.Dot (gravity, contactNormal) * Time.deltaTime);
} else if (climbDetectionActive && isOnGround ()) {
velocity += (gravity - contactNormal * (maxClimbAcceleration * 0.9f)) * Time.deltaTime;
} else {
velocity += gravity * Time.deltaTime;
}
mainRigidbody.linearVelocity = velocity;
mainFreeClimbSystem.updateClimbContactCount (climbContactCount);
mainFreeClimbSystem.updateContactNormal (contactNormal);
mainFreeClimbSystem.updateLastClimbNormal (lastClimbNormal);
clearState ();
}
}
void updateSphereState ()
{
Vector3 rotationPlaneNormal = lastContactNormal;
float rotationFactor = 1f;
if (climbSurfaceDetected ()) {
} else if (!isOnGround ()) {
if (isOnSteep ()) {
rotationPlaneNormal = lastSteepNormal;
} else {
rotationFactor = sphereAirRotation;
}
}
Vector3 movement = (mainRigidbody.linearVelocity - lastConnectionVelocity) * Time.deltaTime;
movement -= rotationPlaneNormal * Vector3.Dot (movement, rotationPlaneNormal);
float distance = movement.magnitude;
Quaternion rotation = sphereTransform.localRotation;
if (connectedBody != null && connectedBody == previousConnectedBody) {
rotation = Quaternion.Euler (connectedBody.angularVelocity * (Mathf.Rad2Deg * Time.deltaTime)) * rotation;
if (distance < 0.001f) {
sphereTransform.localRotation = rotation;
return;
}
} else if (distance < 0.001f) {
return;
}
float angle = distance * rotationFactor * (180f / Mathf.PI) / sphereRadius;
Vector3 rotationAxis = Vector3.Cross (rotationPlaneNormal, movement).normalized;
rotation = Quaternion.Euler (rotationAxis * angle) * rotation;
if (sphereAlignSpeed > 0f) {
rotation = alignSphereRotation (rotationAxis, rotation, distance);
}
sphereTransform.localRotation = rotation;
}
Quaternion alignSphereRotation (Vector3 rotationAxis, Quaternion rotation, float traveledDistance)
{
Vector3 sphereAxis = sphereTransform.up;
float dot = Mathf.Clamp (Vector3.Dot (sphereAxis, rotationAxis), -1f, 1f);
float angle = Mathf.Acos (dot) * Mathf.Rad2Deg;
float maxAngle = sphereAlignSpeed * traveledDistance;
Quaternion newAlignment = Quaternion.FromToRotation (sphereAxis, rotationAxis) * rotation;
if (angle <= maxAngle) {
return newAlignment;
} else {
return Quaternion.SlerpUnclamped (rotation, newAlignment, maxAngle / angle);
}
}
void clearState ()
{
lastContactNormal = contactNormal;
lastSteepNormal = steepNormal;
lastConnectionVelocity = connectionVelocity;
groundContactCount = steepContactCount = climbContactCount = 0;
contactNormal = steepNormal = climbNormal = Vector3.zero;
connectionVelocity = Vector3.zero;
previousConnectedBody = connectedBody;
connectedBody = null;
}
void fixedUpdateSphereState ()
{
stepsSinceLastGrounded += 1;
velocity = mainRigidbody.linearVelocity;
if (checkClimbing () ||
isOnGround () ||
snapToGround () ||
checkSteepContacts ()) {
stepsSinceLastGrounded = 0;
if (groundContactCount > 1) {
contactNormal.Normalize ();
}
} else {
contactNormal = upAxis;
}
if (connectedBody != null) {
if (connectedBody.isKinematic || connectedBody.mass >= mainRigidbody.mass) {
updateConnectionState ();
}
}
}
void updateConnectionState ()
{
if (connectedBody == previousConnectedBody) {
Vector3 connectionMovement = connectedBody.transform.TransformPoint (connectionLocalPosition) - connectionWorldPosition;
connectionVelocity = connectionMovement / Time.deltaTime;
}
connectionWorldPosition = mainRigidbody.position;
connectionLocalPosition = connectedBody.transform.InverseTransformPoint (connectionWorldPosition);
}
bool checkClimbing ()
{
if (climbSurfaceDetected ()) {
if (climbContactCount > 1) {
climbNormal.Normalize ();
float upDot = Vector3.Dot (upAxis, climbNormal);
if (upDot >= minGroundDotProduct) {
climbNormal = lastClimbNormal;
}
}
groundContactCount = 1;
contactNormal = climbNormal;
return true;
}
return false;
}
bool snapToGround ()
{
if (stepsSinceLastGrounded > 1) {
return false;
}
float speed = velocity.magnitude;
if (speed > maxSnapSpeed) {
return false;
}
RaycastHit hit;
if (!Physics.Raycast (mainRigidbody.position, -upAxis, out hit, probeDistance, probeMask, QueryTriggerInteraction.Ignore)) {
return false;
}
Vector3 hitNormal = hit.normal;
float upDot = Vector3.Dot (upAxis, hitNormal);
if (upDot < getMinDot (hit.collider.gameObject.layer)) {
return false;
}
groundContactCount = 1;
contactNormal = hitNormal;
float dot = Vector3.Dot (velocity, hitNormal);
if (dot > 0f) {
velocity = (velocity - hitNormal * dot).normalized * speed;
}
connectedBody = hit.rigidbody;
return true;
}
bool checkSteepContacts ()
{
if (steepContactCount > 1) {
steepNormal.Normalize ();
float upDot = Vector3.Dot (upAxis, steepNormal);
if (upDot >= minGroundDotProduct) {
steepContactCount = 0;
groundContactCount = 1;
contactNormal = steepNormal;
return true;
}
}
return false;
}
void adjustVelocity ()
{
float acceleration, speed;
Vector3 xAxis, zAxis;
float boostInput = mainFreeClimbSystem.getCurrentClimbTurboSpeed ();
bool usingBoost = mainFreeClimbSystem.isTurboActive () && !mainFreeClimbSystem.isPauseTurboActive ();
bool isSlidingDownActive = mainFreeClimbSystem.isSlidingDownActive ();
float currentMaxSpeed = maxSpeed;
if (climbSurfaceDetected ()) {
acceleration = maxClimbAcceleration;
speed = maxHorizontalClimbSpeed;
if (movingDiagonalDown) {
speed = maxDiagonalDownClimbSpeed;
} else if (movingDiagonalUp) {
speed = maxDiagonalUpClimbSpeed;
} else if (movingVertical) {
speed = maxVerticalClimbSpeed;
}
if (isSlidingDownActive) {
speed = maxSlideDownClimbSpeed;
}
if (usingBoost) {
speed *= maxBoostClimbSpeedMultiplier;
}
xAxis = Vector3.Cross (contactNormal, upAxis);
zAxis = upAxis;
} else {
acceleration = isOnGround () ? maxAcceleration : maxAirAcceleration;
float currentClimbSpeed = maxHorizontalClimbSpeed; ;
if (movingDiagonalDown) {
currentClimbSpeed = maxDiagonalDownClimbSpeed;
} else if (movingDiagonalUp) {
currentClimbSpeed = maxDiagonalUpClimbSpeed;
} else if (movingVertical) {
currentClimbSpeed = maxVerticalClimbSpeed;
}
if (isSlidingDownActive) {
speed = maxSlideDownClimbSpeed;
}
if (usingBoost) {
currentClimbSpeed *= maxBoostClimbSpeedMultiplier;
}
speed = isOnGround () && climbDetectionActive ? currentClimbSpeed : currentMaxSpeed;
xAxis = rightAxis;
zAxis = forwardAxis;
}
xAxis = projectDirectionOnPlane (xAxis, contactNormal);
zAxis = projectDirectionOnPlane (zAxis, contactNormal);
if (useCurveSpeedEnabled) {
currentCurveSpeed = 0;
if (movingDiagonalDown) {
currentCurveSpeed = diagonalDownCurveSpeed;
} else if (movingDiagonalUp) {
currentCurveSpeed = diagonalUpCurveSpeed;
} else if (movingVertical) {
currentCurveSpeed = verticalCurveSpeed;
} else if (movingHorizontal) {
currentCurveSpeed = horizontalCurveSpeed;
}
if (isSlidingDownActive) {
currentCurveSpeed = 0;
}
if (currentCurveSpeed != 0) {
var time = Mathf.Repeat ((float)Time.time, 1.0F);
if (usingBoost) {
currentCurveValue = climbBoostSpeedCurve.Evaluate (time) * currentCurveSpeed;
} else {
currentCurveValue = climbSpeedCurve.Evaluate (time) * currentCurveSpeed;
}
}
if (currentCurveValue != 0) {
speed *= currentCurveValue;
}
}
Vector3 relativeVelocity = velocity - connectionVelocity;
Vector3 adjustment;
adjustment.x = moveInput.x * speed - Vector3.Dot (relativeVelocity, xAxis);
adjustment.z = moveInput.z * speed - Vector3.Dot (relativeVelocity, zAxis);
adjustment.y = 0f;
adjustment = Vector3.ClampMagnitude (adjustment, acceleration * Time.deltaTime);
velocity += (xAxis * adjustment.x + zAxis * adjustment.z) * boostInput;
}
bool isOnGround ()
{
return groundContactCount > 0;
}
bool isOnSteep ()
{
return steepContactCount > 0;
}
public bool climbSurfaceDetected ()
{
return climbContactCount > 0;
}
void OnCollisionEnter (Collision collision)
{
EvaluateCollision (collision);
}
void OnCollisionStay (Collision collision)
{
EvaluateCollision (collision);
}
void EvaluateCollision (Collision collision)
{
int layer = collision.gameObject.layer;
float minDot = getMinDot (layer);
for (int i = 0; i < collision.contacts.Length; i++) {
Vector3 normal = collision.contacts [i].normal;
float upDot = Vector3.Dot (upAxis, normal);
if (upDot >= minDot) {
groundContactCount += 1;
contactNormal += normal;
connectedBody = collision.rigidbody;
} else {
if (upDot > -0.01f) {
steepContactCount += 1;
steepNormal += normal;
if (groundContactCount == 0) {
connectedBody = collision.rigidbody;
}
}
if (climbDetectionActive && upDot >= minClimbDotProduct && (climbMask & (1 << layer)) != 0) {
climbContactCount += 1;
climbNormal += normal;
lastClimbNormal = normal;
connectedBody = collision.rigidbody;
}
}
}
}
Vector3 projectDirectionOnPlane (Vector3 direction, Vector3 normal)
{
return (direction - normal * Vector3.Dot (direction, normal)).normalized;
}
float getMinDot (int layer)
{
if ((stairsMask & (1 << layer)) == 0) {
return minGroundDotProduct;
} else {
return minStairsDotProduct;
}
}
public Vector3 getMainRigidbodyVelocity ()
{
return mainRigidbody.linearVelocity;
}
public Vector3 getMainRigidbodyPosition ()
{
return mainRigidbody.position;
}
public Vector3 getLastClimbNormal ()
{
return lastClimbNormal;
}
public Vector3 getContactNormal ()
{
return contactNormal;
}
public void setNewParent (Transform newParent)
{
transform.SetParent (newParent);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 34cf004e2d174964281e39bb96c6106c
timeCreated: 1682591552
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/Extra Movements/climbDetectionCollisionSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 277a9da828efa1a479d62a9d6f71f305
timeCreated: 1641540499
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/Extra Movements/climbRopeSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,87 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class climbRopeTriggerMatchSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool movementZoneActive = true;
public bool checkOnTriggerEnter = true;
public bool checkOnTriggerExit = true;
public string tagToCheck;
[Space]
[Header ("Components")]
[Space]
public climbRopeTriggerSystem mainClimbRopeTriggerSystem;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!movementZoneActive) {
return;
}
if (isEnter) {
if (!checkOnTriggerEnter) {
return;
}
} else {
if (!checkOnTriggerExit) {
return;
}
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior movementExternalControllerBehavior = currentPlayerComponentsManager.getClimbRopeExternaControllerBehavior ();
if (movementExternalControllerBehavior != null) {
climbRopeSystem currentClimbRopeSystem = movementExternalControllerBehavior.GetComponent<climbRopeSystem> ();
currentClimbRopeSystem.addClimbRopeTriggerMatchSystem (this);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior movementExternalControllerBehavior = currentPlayerComponentsManager.getClimbRopeExternaControllerBehavior ();
if (movementExternalControllerBehavior != null) {
climbRopeSystem currentClimbRopeSystem = movementExternalControllerBehavior.GetComponent<climbRopeSystem> ();
currentClimbRopeSystem.removeClimbRopeTriggerMatchSystem (this);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 31299bc7605bd3a449bda73b9459baef
timeCreated: 1641892453
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/Extra Movements/climbRopeTriggerMatchSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,154 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class climbRopeTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool movementZoneActive = true;
public Transform bottomTransform;
public Transform topTransform;
public bool checkOnTriggerEnter = true;
public bool checkOnTriggerExit = true;
public bool setPlayerAsChild = true;
public Transform playerParentTransform;
public bool setNewClimbActionID;
public int newClimbActionID;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEvents;
public bool useRemoteEventOnStart;
public List<string> remoteEventNameListOnStart = new List<string> ();
public bool useRemoteEventOnEnd;
public List<string> remoteEventNameListOnEnd = new List<string> ();
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!movementZoneActive) {
return;
}
if (isEnter) {
if (!checkOnTriggerEnter) {
return;
}
} else {
if (!checkOnTriggerExit) {
return;
}
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior movementExternalControllerBehavior = currentPlayerComponentsManager.getClimbRopeExternaControllerBehavior ();
if (movementExternalControllerBehavior != null) {
climbRopeSystem currentClimbRopeSystem = movementExternalControllerBehavior.GetComponent<climbRopeSystem> ();
if (playerParentTransform == null) {
playerParentTransform = transform;
}
currentClimbRopeSystem.setCurrentClimbRopeTriggerSystem (this);
currentClimbRopeSystem.setSetPlayerAsChildStateState (setPlayerAsChild, playerParentTransform);
currentClimbRopeSystem.setTransformElements (bottomTransform, topTransform);
currentClimbRopeSystem.setMovementSystemActivestate (true);
if (setNewClimbActionID) {
currentClimbRopeSystem.setNewClimbActionID (newClimbActionID);
}
checkRemoteEvents (true, currentPlayer);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior movementExternalControllerBehavior = currentPlayerComponentsManager.getClimbRopeExternaControllerBehavior ();
if (movementExternalControllerBehavior != null) {
climbRopeSystem currentClimbRopeSystem = movementExternalControllerBehavior.GetComponent<climbRopeSystem> ();
currentClimbRopeSystem.setSetPlayerAsChildStateState (false, null);
currentClimbRopeSystem.setMovementSystemActivestate (false);
currentClimbRopeSystem.setTransformElements (null, null);
currentClimbRopeSystem.setOriginalClimbActionID ();
checkRemoteEvents (false, currentPlayer);
}
}
}
}
void checkRemoteEvents (bool state, GameObject objectToCheck)
{
if (!useRemoteEvents) {
return;
}
if (state) {
if (useRemoteEventOnStart) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnStart.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnStart [i]);
}
}
}
} else {
if (useRemoteEventOnEnd) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnEnd.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnEnd [i]);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 78e546c203f384a4ca05eddd5d3423ca
timeCreated: 1641540867
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/Extra Movements/climbRopeTriggerSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,140 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class externalControllerBehavior : MonoBehaviour
{
[Header ("Behavior Main Settings")]
[Space]
public string behaviorName;
public bool externalControllerJumpEnabled;
[Space]
[Header ("Disable Other Behaviors Settings")]
[Space]
public bool canBeActivatedIfOthersBehaviorsActive;
public bool disableAllOthersBehaviorsOnActive;
public List<string> listOfBehaviorToDisableOnActive = new List<string> ();
[Space]
[Header ("Action System Settings")]
[Space]
public int customActionCategoryID = -1;
public int regularActionCategoryID = -1;
[Space]
[Header ("Debug")]
[Space]
public bool behaviorCurrentlyActive;
public virtual void updateControllerBehavior ()
{
}
public virtual bool isCharacterOnGround ()
{
return false;
}
public virtual bool isBehaviorActive ()
{
return false;
}
public virtual void setExternalForceActiveState (bool state)
{
}
public virtual void setExternalForceEnabledState (bool state)
{
}
public virtual void updateExternalForceActiveState (Vector3 forceDirection, float forceAmount)
{
}
public virtual void checkIfActivateExternalForce ()
{
}
public virtual void setJumpActiveForExternalForce ()
{
}
public virtual void setExtraImpulseForce (Vector3 forceAmount, bool useCameraDirection)
{
}
public virtual void disableExternalControllerState ()
{
}
public virtual void checkIfResumeExternalControllerState ()
{
}
public virtual bool checkIfCanEnableBehavior (string behaviorName)
{
if (behaviorName != "") {
if (disableAllOthersBehaviorsOnActive) {
return true;
} else {
if (listOfBehaviorToDisableOnActive.Contains (behaviorName)) {
return true;
} else {
return false;
}
}
} else {
return true;
}
}
public virtual void setBehaviorCurrentlyActiveState (bool state)
{
behaviorCurrentlyActive = state;
}
public virtual bool isBehaviorCurrentlyActive ()
{
return behaviorCurrentlyActive;
}
public virtual void setCurrentPlayerActionSystemCustomActionCategoryID ()
{
}
public virtual void checkPauseStateDuringExternalForceOrBehavior ()
{
}
public virtual void checkResumeStateAfterExternalForceOrBehavior ()
{
}
public virtual void checkChangeCameraViewStateOnExternalControllerBehavior ()
{
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2724654d13705bc449698702051bd993
timeCreated: 1608112213
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/Extra Movements/externalControllerBehavior.cs
uploadId: 814740

View File

@@ -0,0 +1,165 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class externalControllerBehaviorManager : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public List<externalControllerInfo> externalControllerInfoList = new List<externalControllerInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
[Header ("Components")]
[Space]
public playerInputManager mainPlayerInputManager;
public playerWeaponsManager mainPlayerWeaponsManager;
public Transform playerTransform;
bool carryingWeaponsPreviously;
bool aimingWeaponsPrevously;
public void setExternalControllerActive (string nameToCheck)
{
setExternalControllerState (nameToCheck, true);
}
public void setExternalControllerDeactive (string nameToCheck)
{
setExternalControllerState (nameToCheck, false);
}
public void setExternalControllerState (string nameToCheck, bool state)
{
if (nameToCheck == null || nameToCheck == "") {
return;
}
if (showDebugPrint) {
print ("External Controller state " + nameToCheck + " " + state);
}
for (int i = 0; i < externalControllerInfoList.Count; i++) {
externalControllerInfo currentInfo = externalControllerInfoList [i];
if (currentInfo.Name.Equals (nameToCheck)) {
if (showDebugPrint) {
print (nameToCheck + " state found");
}
checkInputListToPauseDuringAction (currentInfo.customInputToPauseOnActionInfoList, state);
if (currentInfo.useEventsOnStateChange) {
if (state) {
currentInfo.eventOnStateActive.Invoke ();
} else {
currentInfo.eventOnStatDeactive.Invoke ();
}
}
if (state) {
carryingWeaponsPreviously = mainPlayerWeaponsManager.isPlayerCarringWeapon ();
aimingWeaponsPrevously = mainPlayerWeaponsManager.isAimingWeapons ();
if (carryingWeaponsPreviously) {
bool stopShootingWeaponActivated = mainPlayerWeaponsManager.stopShootingFireWeaponIfActive ();
if (aimingWeaponsPrevously) {
mainPlayerWeaponsManager.setAimWeaponState (false);
}
if (currentInfo.keepWeaponsDuringAction) {
mainPlayerWeaponsManager.checkIfDisableCurrentWeapon ();
mainPlayerWeaponsManager.resetWeaponHandIKWeight ();
} else if (currentInfo.disableIKWeaponsDuringAction) {
if (!stopShootingWeaponActivated) {
mainPlayerWeaponsManager.stopShootingFireWeaponIfActive ();
}
mainPlayerWeaponsManager.enableOrDisableIKOnWeaponsDuringAction (false);
}
}
if (currentInfo.keepMeleeWeaponGrabbed) {
GKC_Utils.keepMeleeWeaponGrabbed (playerTransform.gameObject);
}
} else {
if (carryingWeaponsPreviously) {
if (currentInfo.drawWeaponsAfterAction) {
mainPlayerWeaponsManager.checkIfDrawSingleOrDualWeapon ();
} else if (currentInfo.disableIKWeaponsDuringAction) {
mainPlayerWeaponsManager.enableOrDisableIKOnWeaponsDuringAction (true);
}
carryingWeaponsPreviously = false;
}
if (currentInfo.drawMeleeWeaponGrabbedOnActionEnd) {
GKC_Utils.drawMeleeWeaponGrabbed (playerTransform.gameObject);
}
}
return;
}
}
}
public void checkInputListToPauseDuringAction (List<playerActionSystem.inputToPauseOnActionIfo> inputList, bool state)
{
for (int i = 0; i < inputList.Count; i++) {
if (state) {
inputList [i].previousActiveState = mainPlayerInputManager.setPlayerInputMultiAxesStateAndGetPreviousState (false, inputList [i].inputName);
} else {
if (inputList [i].previousActiveState) {
mainPlayerInputManager.setPlayerInputMultiAxesState (inputList [i].previousActiveState, inputList [i].inputName);
}
}
}
}
[System.Serializable]
public class externalControllerInfo
{
public string Name;
public externalControllerBehavior mainExternalControllerBehavior;
[Space]
[Space]
public bool keepWeaponsDuringAction = true;
public bool disableIKWeaponsDuringAction = true;
public bool drawWeaponsAfterAction;
public bool keepMeleeWeaponGrabbed = true;
public bool drawMeleeWeaponGrabbedOnActionEnd = true;
[Space]
[Space]
public List<playerActionSystem.inputToPauseOnActionIfo> customInputToPauseOnActionInfoList = new List<playerActionSystem.inputToPauseOnActionIfo> ();
[Space]
[Space]
public bool useEventsOnStateChange;
public UnityEvent eventOnStateActive;
public UnityEvent eventOnStatDeactive;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: f86e7992408aed141b9eb62b247aeede
timeCreated: 1646474653
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/Extra Movements/externalControllerBehaviorManager.cs
uploadId: 814740

View File

@@ -0,0 +1,561 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class flySystem : externalControllerBehavior
{
[Header ("Main Settings")]
[Space]
public bool flyModeEnabled = true;
public float flyForce;
public float airFriction = 5;
public float maxFlyVelocity = 50;
public float flyHorizontalSpeedMultiplier = 1;
public float flyVerticalSpeedMultiplier = 2;
public bool useForceMode = true;
public ForceMode flyForceMode;
[Space]
[Header ("Vertical Movement Settings")]
[Space]
public bool moveUpAndDownEnabled = true;
public float flyMoveUpSpeed = 2;
public float flyMoveDownSpeed = 2;
[Space]
[Header ("Dash Settings")]
[Space]
public bool setNewDashID;
public int newDashID;
[Space]
[Header ("Turbo Settings")]
[Space]
public bool turboEnabled = true;
public float flyTurboSpeed;
[Space]
[Header ("Locked Camera Settings")]
[Space]
public bool useCustomFlyMovementDirectionLockedCamera;
public Transform customFlyMovementDirectionLockedCamera;
[Space]
[Header ("Other Settings")]
[Space]
public float flyRotationSpeedTowardCameraDirection = 10;
public float flySpeedOnAimMultiplier = 0.5f;
public string shakeCameraStateName = "Use Fly Turbo";
[Space]
[Header ("Animation Settings")]
[Space]
public int regularAirID = -1;
public int flyingID = 4;
public string flyingModeName = "Flying Mode";
public bool useIKFlying;
[Space]
[Header ("Debug")]
[Space]
public bool flyModeActive;
public bool turboActive;
public bool playerIsMoving;
public bool movingUp;
public bool movingDown;
public float velocityMagnitude;
public bool flyForcesPaused;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnStateEnabled;
public UnityEvent eventOnStateDisabled;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public playerCamera mainPlayerCamera;
public IKSystem IKManager;
public Rigidbody mainRigidbody;
public Transform mainCameraTransform;
public Transform playerCameraTransform;
public Transform playerTransform;
public dashSystem mainDashSystem;
public Transform COM;
Coroutine resetCOMCoroutine;
Vector3 totalForce;
float currentAimSpeedMultipler;
bool originalFlyModeEnabled;
int previousDashID = -1;
Transform currentLockedCameraTransform;
void Start ()
{
originalFlyModeEnabled = flyModeEnabled;
}
public override void updateControllerBehavior ()
{
//if the player is flying
if (flyModeActive) {
if (flyForcesPaused) {
return;
}
Vector3 mainCameraTransformForward = Vector3.zero;
Vector3 mainCameraTransformRight = Vector3.zero;
Vector3 mainCameraTransformUp = Vector3.zero;
bool isCameraTypeFree = mainPlayerCamera.isCameraTypeFree ();
bool isPlayerMovingOn3dWorld = mainPlayerController.isPlayerMovingOn3dWorld ();
if (isCameraTypeFree) {
mainCameraTransformForward = mainCameraTransform.forward;
mainCameraTransformRight = mainCameraTransform.right;
} else {
if (useCustomFlyMovementDirectionLockedCamera && isPlayerMovingOn3dWorld) {
currentLockedCameraTransform = customFlyMovementDirectionLockedCamera;
} else {
currentLockedCameraTransform = mainPlayerCamera.getLockedCameraTransform ();
}
mainCameraTransformForward = currentLockedCameraTransform.forward;
mainCameraTransformRight = currentLockedCameraTransform.right;
mainCameraTransformUp = currentLockedCameraTransform.up;
}
Vector3 targetDirection = Vector3.zero;
if (isPlayerMovingOn3dWorld) {
targetDirection = mainCameraTransformForward * (mainPlayerController.getVerticalInput () * flyVerticalSpeedMultiplier) +
mainCameraTransformRight * (mainPlayerController.getHorizontalInput () * flyHorizontalSpeedMultiplier);
if (!isCameraTypeFree && useCustomFlyMovementDirectionLockedCamera) {
Vector3 localMove = playerTransform.InverseTransformDirection (targetDirection);
targetDirection = localMove;
}
} else {
targetDirection = mainCameraTransformUp * (mainPlayerController.getVerticalInput () * flyVerticalSpeedMultiplier) +
mainCameraTransformRight * (mainPlayerController.getHorizontalInput () * flyHorizontalSpeedMultiplier);
}
playerIsMoving = mainPlayerController.isPlayerMoving (0.1f);
if (!mainPlayerController.isPlayerOnFirstPerson () && !mainPlayerController.isPlayerRotatingToSurface ()) {
if (isPlayerMovingOn3dWorld) {
Quaternion COMTargetRotation = Quaternion.identity;
bool isPlayerUsingWeapons = mainPlayerController.isPlayerUsingWeapons ();
if (mainPlayerController.isFullBodyAwarenessActive () && isPlayerUsingWeapons) {
float angleDifference = Quaternion.Angle (COM.localRotation, COMTargetRotation);
if (angleDifference > 0.05f) {
COM.localRotation = Quaternion.Lerp (COM.localRotation, COMTargetRotation,
flyRotationSpeedTowardCameraDirection * Time.fixedDeltaTime);
}
} else {
if ((playerIsMoving && targetDirection != Vector3.zero) || (!isCameraTypeFree && !isPlayerUsingWeapons)) {
float currentLookAngle = 0;
if (isCameraTypeFree) {
currentLookAngle = Vector3.SignedAngle (playerCameraTransform.forward, mainCameraTransformForward, playerCameraTransform.right);
}
if (Mathf.Abs (currentLookAngle) > 10 && !mainPlayerController.isPlayerAiming ()) {
if (turboActive) {
currentLookAngle = Mathf.Clamp (currentLookAngle, -50, 50);
} else {
currentLookAngle = Mathf.Clamp (currentLookAngle, -30, 30);
}
} else {
currentLookAngle = 0;
}
COMTargetRotation = Quaternion.Euler (Vector3.right * currentLookAngle);
Quaternion targetRotation = Quaternion.identity;
if (isCameraTypeFree) {
targetRotation = playerCameraTransform.rotation;
} else {
targetRotation = currentLockedCameraTransform.rotation;
}
playerTransform.rotation = Quaternion.Lerp (playerTransform.rotation, targetRotation,
flyRotationSpeedTowardCameraDirection * Time.fixedDeltaTime);
}
COM.localRotation = Quaternion.Lerp (COM.localRotation, COMTargetRotation,
flyRotationSpeedTowardCameraDirection * Time.fixedDeltaTime);
}
}
}
currentAimSpeedMultipler = 1;
if (!mainPlayerController.isPlayerOnFirstPerson () && mainPlayerController.isPlayerAiming ()) {
currentAimSpeedMultipler = flySpeedOnAimMultiplier;
}
totalForce = targetDirection * (flyForce * currentAimSpeedMultipler);
if (isPlayerMovingOn3dWorld) {
if (movingUp) {
totalForce += playerTransform.up * flyMoveUpSpeed;
playerIsMoving = true;
}
if (movingDown) {
totalForce -= playerTransform.up * flyMoveDownSpeed;
playerIsMoving = true;
}
}
if (playerIsMoving) {
if (turboActive) {
totalForce *= flyTurboSpeed;
}
velocityMagnitude = totalForce.magnitude;
if (velocityMagnitude > maxFlyVelocity) {
totalForce = Vector3.ClampMagnitude (totalForce, maxFlyVelocity);
}
velocityMagnitude = totalForce.magnitude;
if (useForceMode) {
mainRigidbody.AddForce (totalForce, flyForceMode);
} else {
mainRigidbody.AddForce (totalForce);
}
} else {
velocityMagnitude = mainRigidbody.linearVelocity.magnitude;
if (velocityMagnitude > 0) {
totalForce = mainRigidbody.linearVelocity * (-1 * airFriction);
}
mainRigidbody.AddForce (totalForce, flyForceMode);
}
}
}
public void enableOrDisableFlyingMode (bool state)
{
if (!flyModeEnabled) {
return;
}
if (mainPlayerController.isUseExternalControllerBehaviorPaused ()) {
return;
}
if (flyModeActive == state) {
return;
}
if (state) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior != null && currentExternalControllerBehavior != this) {
if (canBeActivatedIfOthersBehaviorsActive && checkIfCanEnableBehavior (currentExternalControllerBehavior.behaviorName)) {
currentExternalControllerBehavior.disableExternalControllerState ();
} else {
return;
}
}
}
bool flyModeActivePrevioulsy = flyModeActive;
flyModeActive = state;
mainPlayerController.enableOrDisableFlyingMode (state);
setBehaviorCurrentlyActiveState (state);
setCurrentPlayerActionSystemCustomActionCategoryID ();
if (flyModeActive) {
mainPlayerController.setExternalControllerBehavior (this);
} else {
if (flyModeActivePrevioulsy) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior == null || currentExternalControllerBehavior == this) {
mainPlayerController.setExternalControllerBehavior (null);
}
}
}
if (useIKFlying) {
IKManager.setIKBodyState (state, flyingModeName);
}
if (!state) {
mainPlayerController.setLastTimeFalling ();
}
if (state) {
mainPlayerController.setCurrentAirIDValue (flyingID);
} else {
mainPlayerController.setCurrentAirIDValue (regularAirID);
mainPlayerController.setCurrentAirSpeedValue (1);
}
if (setNewDashID) {
if (mainDashSystem != null) {
if (state) {
if (previousDashID == -1) {
previousDashID = mainDashSystem.getCurrentDashID ();
}
mainDashSystem.setCheckGroundPausedState (true);
mainDashSystem.setOverrideStrafeModeActiveStateResult (true);
mainDashSystem.setCurrentDashID (newDashID);
} else {
if (previousDashID != -1) {
mainDashSystem.setCurrentDashID (previousDashID);
previousDashID = -1;
mainDashSystem.setCheckGroundPausedState (false);
mainDashSystem.setOverrideStrafeModeActiveStateResult (false);
}
}
}
}
if (flyModeActive) {
eventOnStateEnabled.Invoke ();
} else {
eventOnStateDisabled.Invoke ();
resetCOMRotation ();
if (turboActive) {
enableOrDisableTurbo (false);
}
enableOrDisableVerticalMovementUp (false);
enableOrDisableVerticalMovementDown (false);
}
mainPlayerCamera.stopShakeCamera ();
if (flyModeActive) {
mainPlayerController.setPlayerOnGroundState (false);
mainPlayerController.setOnGroundAnimatorIDValue (false);
mainPlayerController.setPreviousValueOnGroundAnimatorStateValue (false);
}
movingUp = false;
movingDown = false;
}
public void enableOrDisableTurbo (bool state)
{
turboActive = state;
mainPlayerController.enableOrDisableFlyModeTurbo (turboActive);
mainPlayerCamera.changeCameraFov (turboActive);
//when the player accelerates his movement in the air, the camera shakes
if (turboActive) {
mainPlayerCamera.setShakeCameraState (true, shakeCameraStateName);
} else {
mainPlayerCamera.setShakeCameraState (false, "");
mainPlayerCamera.stopShakeCamera ();
}
if (turboActive) {
mainPlayerController.setCurrentAirSpeedValue (2);
} else {
mainPlayerController.setCurrentAirSpeedValue (1);
}
}
public void resetCOMRotation ()
{
if (resetCOMCoroutine != null) {
StopCoroutine (resetCOMCoroutine);
}
resetCOMCoroutine = StartCoroutine (resetCOMRotationCoroutine ());
}
public IEnumerator resetCOMRotationCoroutine ()
{
for (float t = 0; t < 1;) {
t += Time.deltaTime * 4;
COM.localRotation = Quaternion.Slerp (COM.localRotation, Quaternion.identity, t);
yield return null;
}
}
public void inputChangeTurboState (bool state)
{
if (flyModeActive && turboEnabled) {
enableOrDisableTurbo (state);
}
}
public void inputMoveUp (bool state)
{
if (flyModeActive && moveUpAndDownEnabled) {
enableOrDisableVerticalMovementUp (state);
}
}
public void inputMoveDown (bool state)
{
if (flyModeActive && moveUpAndDownEnabled) {
enableOrDisableVerticalMovementDown (state);
}
}
void enableOrDisableVerticalMovementUp (bool state)
{
movingUp = state;
if (movingUp) {
movingDown = false;
}
}
void enableOrDisableVerticalMovementDown (bool state)
{
movingDown = state;
if (movingDown) {
movingUp = false;
}
}
public void setFlyModeEnabledState (bool state)
{
if (flyModeActive) {
enableOrDisableFlyingMode (false);
}
flyModeEnabled = state;
}
public void setOriginalFlyModeEnabledState ()
{
setFlyModeEnabledState (originalFlyModeEnabled);
}
public override void disableExternalControllerState ()
{
enableOrDisableFlyingMode (false);
}
public override void setCurrentPlayerActionSystemCustomActionCategoryID ()
{
if (behaviorCurrentlyActive) {
if (customActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (customActionCategoryID);
}
} else {
if (regularActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (regularActionCategoryID);
}
}
}
public override void checkPauseStateDuringExternalForceOrBehavior ()
{
flyForcesPaused = true;
}
public override void checkResumeStateAfterExternalForceOrBehavior ()
{
if (flyModeActive) {
setCurrentPlayerActionSystemCustomActionCategoryID ();
flyForcesPaused = false;
}
}
public void setEnableExternalForceOnFlyModeState (bool state)
{
if (flyModeActive) {
mainPlayerController.setEnableExternalForceOnFlyModeState (state);
}
}
public void setFlyModeEnabledStateFromEditor (bool state)
{
setFlyModeEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Fly System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a98d7a433a016334a995b26efd31c0eb
timeCreated: 1472232124
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/Extra Movements/flySystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 543ec5a1b3d90d04fae53cfc97180869
timeCreated: 1660901422
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/Extra Movements/freeClimbSystem.cs.bak
uploadId: 814740

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 902d7024813923e43af96cec4f0e5cb7
timeCreated: 1655176838
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/Extra Movements/freeClimbSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,145 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class freeClimbSystemIK : OnAnimatorIKComponent
{
[Header ("Main Settings")]
[Space]
public bool climbSystemIKActive;
public LayerMask layerMask;
public float IKWeightEnabledSpeed = 10;
public float IKWeightDisabledSpeed = 2;
public float raycastDistance = 1.3f;
public List<bodyPartIKInfo> bodyPartIKInfoList = new List<bodyPartIKInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool playerIsMoving;
[Space]
[Header ("Components")]
[Space]
public freeClimbSystem mainFreeClimbSystem;
public Animator mainAnimator;
public Transform playerTransform;
RaycastHit hit;
bool checkRaycast;
Vector3 currentTransformForward;
AvatarIKGoal currentIKGoal;
float minIKValue = 0.001f;
float currentAdjustmentSpeed;
bodyPartIKInfo currentBodyPartIKInfo;
int bodyPartIKInfoListCount;
public override void updateOnAnimatorIKState ()
{
if (!updateIKEnabled) {
return;
}
if (!mainFreeClimbSystem.climbActive) {
return;
}
currentTransformForward = playerTransform.forward;
bool isPlayerMoving = mainFreeClimbSystem.isPlayerMoving ();
float currentDeltatime = Time.fixedDeltaTime;
for (int i = 0; i < bodyPartIKInfoListCount; i++) {
currentBodyPartIKInfo = bodyPartIKInfoList [i];
AvatarIKGoal currentIKGoal = currentBodyPartIKInfo.IKGoal;
checkRaycast = true;
currentBodyPartIKInfo.targetWeight = 0;
currentAdjustmentSpeed = IKWeightDisabledSpeed;
if (isPlayerMoving) {
checkRaycast = false;
}
if (checkRaycast) {
Vector3 direction = currentTransformForward;
if (Physics.Raycast (currentBodyPartIKInfo.IKGoalTransform.position - direction, direction, out hit, raycastDistance, layerMask)) {
currentBodyPartIKInfo.newBodyPartPosition = hit.point - direction * currentBodyPartIKInfo.bodyPartOffset;
currentBodyPartIKInfo.targetWeight = 1;
currentAdjustmentSpeed = IKWeightEnabledSpeed;
}
}
currentBodyPartIKInfo.IKWeight =
Mathf.Clamp01 (Mathf.Lerp (currentBodyPartIKInfo.IKWeight, currentBodyPartIKInfo.targetWeight, currentAdjustmentSpeed * currentDeltatime));
if (currentBodyPartIKInfo.IKWeight >= minIKValue) {
mainAnimator.SetIKPosition (currentIKGoal, currentBodyPartIKInfo.newBodyPartPosition);
mainAnimator.SetIKPositionWeight (currentIKGoal, currentBodyPartIKInfo.IKWeight);
}
}
}
public override void setActiveState (bool state)
{
climbSystemIKActive = state;
if (climbSystemIKActive) {
bodyPartIKInfoListCount = bodyPartIKInfoList.Count;
for (int i = 0; i < bodyPartIKInfoListCount; i++) {
if (bodyPartIKInfoList [i].IKGoalTransform == null) {
bodyPartIKInfoList [i].IKGoalTransform = mainAnimator.GetBoneTransform (bodyPartIKInfoList [i].mainBone);
}
bodyPartIKInfoList [i].IKWeight = 0;
bodyPartIKInfoList [i].targetWeight = 0;
bodyPartIKInfoList [i].newBodyPartPosition = Vector3.zero;
}
} else {
}
}
[System.Serializable]
public class bodyPartIKInfo
{
public string Name;
public AvatarIKGoal IKGoal;
public HumanBodyBones mainBone;
public Transform IKGoalTransform;
public float IKWeight;
public float targetWeight;
public Vector3 newBodyPartPosition;
public float bodyPartOffset = 0.1f;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8addac3fcdec1094e81ad84f03b79957
timeCreated: 1659294896
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/Extra Movements/freeClimbSystemIK.cs
uploadId: 814740

View File

@@ -0,0 +1,144 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class freeClimbZoneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool climbZoneActive = true;
public bool activateClimbCheckOnTriggerEnter = true;
public bool stopClimbOnTriggerExit;
public bool activateClimbStateAutomaticallyOnEnter;
public bool climbAutomaticallyOnlyIfPlayerOnAir;
[Space]
[Header ("Action Settings")]
[Space]
public bool ignoreSurfaceToClimbEnabled;
public bool allowClimbSurfaceOnInputEnabled;
public bool activateAutoSlideDownOnSurface;
public bool movementInputDisabledOnSurface;
[Space]
[Header ("Other Settings")]
[Space]
public bool setPlayerAsChild;
public Transform playerParentTransform;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!climbZoneActive) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior freeClimbExteralControllerBehavior = currentPlayerComponentsManager.getFreeClimbExternalControllerBehavior ();
if (freeClimbExteralControllerBehavior != null) {
freeClimbSystem currentFreeClimbSystem = freeClimbExteralControllerBehavior.GetComponent<freeClimbSystem> ();
if (activateClimbCheckOnTriggerEnter) {
currentFreeClimbSystem.setCheckIfDetectClimbActiveState (true);
if (activateClimbStateAutomaticallyOnEnter) {
bool canActivateClimbStateResult = true;
if (climbAutomaticallyOnlyIfPlayerOnAir) {
if (currentPlayerComponentsManager.getPlayerController ().isPlayerOnGround ()) {
canActivateClimbStateResult = false;
}
}
if (canActivateClimbStateResult) {
currentFreeClimbSystem.activateGrabSurface ();
}
}
// if (movementInputDisabledOnSurface) {
// currentFreeClimbSystem.setMovementInputDisabledOnSurfaceState (true);
// }
}
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior freeClimbExteralControllerBehavior = currentPlayerComponentsManager.getFreeClimbExternalControllerBehavior ();
if (freeClimbExteralControllerBehavior != null) {
freeClimbSystem currentFreeClimbSystem = freeClimbExteralControllerBehavior.GetComponent<freeClimbSystem> ();
if (stopClimbOnTriggerExit) {
currentFreeClimbSystem.setCheckIfDetectClimbActiveState (false);
}
// if (movementInputDisabledOnSurface) {
// currentFreeClimbSystem.setMovementInputDisabledOnSurfaceState (false);
// }
}
}
}
}
public Transform checkPlayerParentState ()
{
if (setPlayerAsChild) {
return playerParentTransform;
}
return null;
}
public bool isIgnoreSurfaceToClimbEnabled ()
{
return ignoreSurfaceToClimbEnabled;
}
public void setIgnoreSurfaceToClimbEnabledState (bool state)
{
ignoreSurfaceToClimbEnabled = state;
}
public bool isAllowClimbSurfaceOnInputEnabled ()
{
return allowClimbSurfaceOnInputEnabled;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 8fd5dfcee1de27f44838c409bf8ef66b
timeCreated: 1655185750
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/Extra Movements/freeClimbZoneSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,329 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class freeFallCharacterActivator : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool checkCharacterFallEnabled = true;
public float minTimeOnAirToActivateFreeFall = 2;
public int regularAirID = -1;
public int freeFallID = 3;
public bool setNewCameraStateOnFreeFallActive;
public string newCameraStateOnFreeFall;
public Vector3 capsuleColliderCenter = new Vector3 (0, 1, 0);
public bool useMinFallSpeedToActivateState;
public float minFallSpeedToActivateState;
public bool avoidFallDamageOnFreeFall;
public bool avoidFallDamageOnFreeFallOnlyOnTurbo;
[Space]
[Header ("Turbo Settings")]
[Space]
public bool fallTurboEnabled = true;
public float fallTurboMultiplier = 2;
public bool useCameraShake;
public string regularCameraShakeName;
public bool useMaxFallSpeed;
public float maxFallSpeed;
[Space]
public bool useEventOnLandingWithTurbo;
public UnityEvent eventOnLandingWithTurbo;
[Space]
[Header ("Debug")]
[Space]
public bool checkingFreeFall;
public bool freeFallActive;
public bool freeFallPaused;
public bool fallTurboActive;
[Space]
[Header ("Event Settings")]
[Space]
public bool useEventsOnFreeFallStateChange;
public UnityEvent eventOnFreeFallActive;
public UnityEvent eventOnFreeFallDeactivate;
[Space]
[Header ("Components")]
[Space]
public playerCamera mainPlayerCamera;
public playerController mainPlayerController;
float lastTimeFalling;
float lastTimeJump;
string previousCameraState;
bool resetCheckOnFreeFallActive;
void Update ()
{
if (checkCharacterFallEnabled) {
if (freeFallPaused) {
return;
}
if (!checkingFreeFall) {
if (!mainPlayerController.isPlayerOnGround () &&
mainPlayerController.getCurrentAirID () == regularAirID &&
!mainPlayerController.isExternalControlBehaviorForAirTypeActive () &&
!mainPlayerController.isPlayerDriving ()) {
checkingFreeFall = true;
lastTimeFalling = Time.time;
}
} else {
if (!freeFallActive) {
if (Time.time > minTimeOnAirToActivateFreeFall + lastTimeFalling && checkFallSpeed ()) {
if (mainPlayerController.getCurrentAirID () == regularAirID) {
setFreeFallState (true);
} else {
checkingFreeFall = false;
}
} else {
if (mainPlayerController.isPlayerOnGround () ||
mainPlayerController.isActionActive () ||
mainPlayerController.isGravityPowerActive () ||
mainPlayerController.isPlayerOnFFOrZeroGravityModeOn () ||
mainPlayerController.isChoosingGravityDirection () ||
mainPlayerController.isGravityForcePaused () ||
mainPlayerController.isWallRunningActive () ||
mainPlayerController.isSwimModeActive () ||
mainPlayerController.isSphereModeActive () ||
mainPlayerController.isExternalControlBehaviorForAirTypeActive () ||
mainPlayerController.isPlayerDriving () ||
mainPlayerController.isSlowFallExternallyActive ()) {
setFreeFallState (false);
}
}
} else {
if (mainPlayerController.isPlayerOnGround () ||
mainPlayerController.isPlayerAiming () ||
lastTimeJump != mainPlayerController.getLastDoubleJumpTime () ||
mainPlayerController.isExternalControlBehaviorForAirTypeActive () ||
resetCheckOnFreeFallActive) {
resetRegularPlayerValues ();
disableFreeFallActiveState ();
}
if (mainPlayerController.getCurrentAirID () != freeFallID) {
disableFreeFallActiveState ();
}
}
}
}
}
public void disableFreeFallActiveState ()
{
resetCheckOnFreeFallActive = false;
setFreeFallState (false);
}
public void setFreeFallPausedState (bool state)
{
if (!state) {
if (freeFallActive) {
resetRegularPlayerValues ();
disableFreeFallActiveState ();
}
}
freeFallPaused = state;
}
public bool checkFallSpeed ()
{
if (useMinFallSpeedToActivateState) {
if (Mathf.Abs (mainPlayerController.getVerticalSpeed ()) > minFallSpeedToActivateState) {
return true;
} else {
return false;
}
}
return true;
}
public void setResetCheckOnFreeFallActiveState (bool state)
{
resetCheckOnFreeFallActive = state;
}
public void inputEnableOrDisableFallTurbo (bool state)
{
if (!fallTurboEnabled) {
return;
}
if (freeFallActive) {
setTurboState (state);
}
}
void setTurboState (bool state)
{
if (fallTurboActive == state) {
return;
}
fallTurboActive = state;
if (fallTurboActive) {
mainPlayerController.setGravityMultiplierValueFromExternalFunction (fallTurboMultiplier);
mainPlayerController.setCurrentAirSpeedValue (2);
if (useCameraShake) {
mainPlayerCamera.setShakeCameraState (true, regularCameraShakeName);
}
} else {
mainPlayerController.setGravityMultiplierValue (true, 0);
mainPlayerController.setCurrentAirSpeedValue (1);
if (useCameraShake) {
mainPlayerCamera.setShakeCameraState (false, "");
}
}
if (avoidFallDamageOnFreeFall && avoidFallDamageOnFreeFallOnlyOnTurbo) {
mainPlayerController.setFallDamageCheckOnHealthPausedState (state);
}
if (useMaxFallSpeed) {
mainPlayerController.setUseMaxFallSpeedExternallyActiveState (state);
if (state) {
mainPlayerController.setCustomMaxFallSpeedExternally (maxFallSpeed);
} else {
mainPlayerController.setCustomMaxFallSpeedExternally (0);
}
}
}
void setFreeFallState (bool state)
{
if (state) {
freeFallActive = true;
mainPlayerController.setCurrentAirIDValue (freeFallID);
mainPlayerController.setPlayerCapsuleColliderDirection (2);
mainPlayerController.setPlayerColliderCapsuleCenter (capsuleColliderCenter);
lastTimeJump = mainPlayerController.getLastDoubleJumpTime ();
if (setNewCameraStateOnFreeFallActive) {
previousCameraState = mainPlayerCamera.getCurrentStateName ();
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (newCameraStateOnFreeFall);
}
if (avoidFallDamageOnFreeFall && !avoidFallDamageOnFreeFallOnlyOnTurbo) {
mainPlayerController.setFallDamageCheckOnHealthPausedState (true);
}
} else {
if (avoidFallDamageOnFreeFall) {
mainPlayerController.setFallDamageCheckOnHealthPausedState (false);
}
if (fallTurboActive) {
if (useEventOnLandingWithTurbo) {
if (mainPlayerController.checkIfPlayerOnGroundWithRaycast () || mainPlayerController.isPlayerOnGround ()) {
eventOnLandingWithTurbo.Invoke ();
}
}
setTurboState (false);
}
checkingFreeFall = false;
freeFallActive = false;
if (setNewCameraStateOnFreeFallActive) {
if (previousCameraState != "") {
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (previousCameraState);
previousCameraState = "";
}
}
if (useMaxFallSpeed) {
mainPlayerController.setUseMaxFallSpeedExternallyActiveState (false);
mainPlayerController.setCustomMaxFallSpeedExternally (0);
}
}
checkEventsOnFreeFallStateChange (state);
}
public void stopFreeFallStateIfActive ()
{
if (freeFallActive) {
resetRegularPlayerValues ();
disableFreeFallActiveState ();
}
}
void resetRegularPlayerValues ()
{
if (mainPlayerController.getCurrentAirID () == freeFallID) {
mainPlayerController.setCurrentAirIDValue (regularAirID);
mainPlayerController.setPlayerCapsuleColliderDirection (1);
mainPlayerController.setOriginalPlayerColliderCapsuleScale ();
}
}
void checkEventsOnFreeFallStateChange (bool state)
{
if (useEventsOnFreeFallStateChange) {
if (state) {
eventOnFreeFallActive.Invoke ();
} else {
eventOnFreeFallDeactivate.Invoke ();
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d88ceceb9b7d35742b983e34d2f62662
timeCreated: 1621379777
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/Extra Movements/freeFallCharacterActivator.cs
uploadId: 814740

View File

@@ -0,0 +1,630 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.Events;
public class jetpackSystem : externalControllerBehavior
{
[Header ("Main Setting")]
[Space]
public bool jetpackEnabled;
public float jetpackForce;
public float jetpackAirSpeed;
public float jetpackAirControl;
public bool turboEnabled = true;
public float jetpackTurboHorizontalSpeed = 5;
public float jetpackTurboVerticalSpeed = 5;
public bool useForceMode;
public ForceMode forceMode;
[Space]
[Header ("Other Settings")]
[Space]
public bool disableJetpackMeshWhenNotEquipped = true;
public float jetpackHorizontalSpeedOnAimMultiplier = 0.5f;
public float jetpackVerticalSpeedOnAimMultiplier = 0.5f;
public string shakeCameraStateName = "Use Jetpack Turbo";
[Space]
public bool useCustomJetpackUpDirection;
public Transform customJetpackUpDirection;
public bool usedByAI;
[Space]
[Header ("Fuel Settings")]
[Space]
public float jetpackFuelAmount;
public float jetpackFuelRate;
public float regenerativeSpeed;
public float timeToRegenerate;
[Space]
[Header ("Animation Settings")]
[Space]
public bool useJetpackAnimation = true;
public string jetpackModeName = "Jetpack Mode";
public int regularAirID = -1;
public int jetpackID = 2;
public bool useIKJetpack;
public string animationName;
[Space]
[Header ("Particles Settings")]
[Space]
public List<ParticleSystem> thrustsParticles = new List<ParticleSystem> ();
[Space]
[Header ("Debug")]
[Space]
public bool jetPackEquiped;
public bool usingJetpack;
public bool turboActive;
public bool jetpackModePaused;
[Space]
[Header ("Event Setting")]
[Space]
public UnityEvent eventOnStartUsingJetpack;
public UnityEvent eventOnStopUsingJetpack;
public UnityEvent eventOnStateEnabled;
public UnityEvent eventOnStateDisabled;
[Space]
[Header ("Components")]
[Space]
public GameObject jetpack;
public GameObject jetpackHUDInfo;
public Slider jetpackSlider;
public Text fuelAmountText;
public playerController mainPlayerController;
public playerCamera mainPlayerCamera;
public Animation jetPackAnimation;
public IKSystem IKManager;
public Transform playerTransform;
public Rigidbody mainRigidbody;
bool hudEnabled;
float lastTimeUsed;
Vector3 airMove;
float currentHorizontalAimSpeedMultipler;
float currentVerticalAimSpeedMultipler;
Vector3 totalForce;
bool playerIsAiming;
bool turboActivePreviously;
bool originalJetpackEnabled;
externalControllerBehavior previousExternalControllerBehavior;
void Start ()
{
if (usedByAI) {
return;
}
if (jetpack == null) {
jetpackEnabled = false;
return;
}
changeThrustsParticlesState (false);
if (jetpackFuelAmount > 0) {
jetpackSlider.maxValue = jetpackFuelAmount;
jetpackSlider.value = jetpackFuelAmount;
hudEnabled = true;
updateJetpackUIInfo ();
}
if (!jetpackEnabled || disableJetpackMeshWhenNotEquipped) {
if (jetpack.activeSelf) {
jetpack.SetActive (false);
}
}
originalJetpackEnabled = jetpackEnabled;
}
public override void updateControllerBehavior ()
{
if (usedByAI) {
return;
}
if (jetPackEquiped) {
//if the player is using the jetpack
if (usingJetpack) {
currentHorizontalAimSpeedMultipler = 1;
currentVerticalAimSpeedMultipler = 1;
playerIsAiming = mainPlayerController.isPlayerAiming ();
if (!mainPlayerController.isPlayerOnFirstPerson () && playerIsAiming) {
currentHorizontalAimSpeedMultipler = jetpackHorizontalSpeedOnAimMultiplier;
currentVerticalAimSpeedMultipler = jetpackVerticalSpeedOnAimMultiplier;
}
airMove = mainPlayerController.getMoveInputDirection () * (jetpackAirSpeed * currentHorizontalAimSpeedMultipler);
if (turboActive) {
airMove *= jetpackTurboHorizontalSpeed;
}
Vector3 currentUpDirection = playerTransform.up;
if (useCustomJetpackUpDirection) {
currentUpDirection = customJetpackUpDirection.up;
}
airMove += playerTransform.InverseTransformDirection (mainPlayerController.currentVelocity).y * currentUpDirection;
mainPlayerController.currentVelocity = Vector3.Lerp (mainPlayerController.currentVelocity, airMove, Time.fixedDeltaTime * jetpackAirControl);
totalForce = currentUpDirection * (-mainPlayerController.getGravityForce () * mainRigidbody.mass * jetpackForce * currentVerticalAimSpeedMultipler);
if (turboActive) {
totalForce *= jetpackTurboVerticalSpeed;
}
if (useForceMode) {
mainRigidbody.AddForce (totalForce, forceMode);
} else {
mainRigidbody.AddForce (totalForce);
}
if (playerIsAiming) {
if (turboActive) {
if (!turboActivePreviously) {
turboActivePreviously = true;
enableOrDisableTurbo (false);
}
}
} else {
if (turboActivePreviously) {
enableOrDisableTurbo (true);
turboActivePreviously = false;
}
}
}
if (mainPlayerController.isPlayerOnFFOrZeroGravityModeOn ()) {
enableOrDisableJetpack (false);
}
if (usingJetpack) {
mainPlayerController.setPlayerOnGroundState (false);
if (hudEnabled) {
jetpackFuelAmount -= Time.deltaTime * jetpackFuelRate;
updateJetpackUIInfo ();
jetpackSlider.value = jetpackFuelAmount;
}
if (jetpackFuelAmount <= 0) {
startOrStopJetpack (false);
}
} else {
if (regenerativeSpeed > 0 && lastTimeUsed != 0) {
if (Time.time > lastTimeUsed + timeToRegenerate) {
jetpackFuelAmount += regenerativeSpeed * Time.deltaTime;
if (jetpackFuelAmount >= jetpackSlider.maxValue) {
jetpackFuelAmount = jetpackSlider.maxValue;
lastTimeUsed = 0;
}
updateJetpackUIInfo ();
jetpackSlider.value = jetpackFuelAmount;
}
}
}
}
}
void updateJetpackUIInfo ()
{
//jetpackSlider.maxValue.ToString ("0") + " / " +
fuelAmountText.text = jetpackFuelAmount.ToString ("0");
}
public bool canUseJetpack ()
{
bool value = false;
if (jetpackFuelAmount > 0) {
value = true;
}
if (jetpackModePaused) {
value = false;
}
return value;
}
public void startOrStopJetpack (bool state)
{
if (usingJetpack != state) {
usingJetpack = state;
if (useJetpackAnimation) {
if (usingJetpack) {
jetPackAnimation [animationName].speed = 1;
jetPackAnimation.Play (animationName);
} else {
jetPackAnimation [animationName].speed = -1;
jetPackAnimation [animationName].time = jetPackAnimation [animationName].length;
jetPackAnimation.Play (animationName);
}
}
if (usingJetpack) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior != this) {
if (previousExternalControllerBehavior == null && currentExternalControllerBehavior != null) {
previousExternalControllerBehavior = currentExternalControllerBehavior;
}
mainPlayerController.setExternalControllerBehavior (this);
}
}
mainPlayerController.setUsingJetpackState (usingJetpack);
if (!usingJetpack) {
mainPlayerController.setLastTimeFalling ();
lastTimeUsed = Time.time;
}
changeThrustsParticlesState (usingJetpack);
if (useIKJetpack) {
IKManager.setIKBodyState (usingJetpack, jetpackModeName);
}
if (usingJetpack) {
mainPlayerController.setCurrentAirIDValue (jetpackID);
} else {
mainPlayerController.setCurrentAirIDValue (regularAirID);
}
if (usingJetpack) {
eventOnStartUsingJetpack.Invoke ();
} else {
eventOnStopUsingJetpack.Invoke ();
}
if (!usingJetpack) {
if (turboActive) {
enableOrDisableTurbo (false);
}
}
turboActivePreviously = false;
}
}
public void changeThrustsParticlesState (bool state)
{
for (int i = 0; i < thrustsParticles.Count; i++) {
if (state) {
if (!thrustsParticles [i].isPlaying) {
thrustsParticles [i].gameObject.SetActive (true);
thrustsParticles [i].Play ();
var boostingParticlesMain = thrustsParticles [i].main;
boostingParticlesMain.loop = true;
}
} else {
if (thrustsParticles [i].isPlaying) {
var boostingParticlesMain = thrustsParticles [i].main;
boostingParticlesMain.loop = false;
}
}
}
}
public void enableOrDisableJetpack (bool state)
{
if (!jetpackEnabled && state) {
return;
}
if (jetPackEquiped == state) {
return;
}
if (mainPlayerController.isUseExternalControllerBehaviorPaused ()) {
return;
}
if (jetpackModePaused && state) {
return;
}
if (state) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior != null && currentExternalControllerBehavior != this) {
if (canBeActivatedIfOthersBehaviorsActive && checkIfCanEnableBehavior (currentExternalControllerBehavior.behaviorName)) {
currentExternalControllerBehavior.disableExternalControllerState ();
} else {
return;
}
}
}
bool jetpackEquipedPreviously = jetPackEquiped;
jetPackEquiped = state;
mainPlayerController.equipJetpack (state);
setBehaviorCurrentlyActiveState (state);
setCurrentPlayerActionSystemCustomActionCategoryID ();
if (jetPackEquiped) {
if (previousExternalControllerBehavior == null) {
previousExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (previousExternalControllerBehavior == this) {
previousExternalControllerBehavior = null;
}
}
mainPlayerController.setExternalControllerBehavior (this);
} else {
if (jetpackEquipedPreviously) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior == null || currentExternalControllerBehavior == this) {
mainPlayerController.setExternalControllerBehavior (null);
}
}
}
if (jetPackEquiped) {
if (hudEnabled) {
if (jetpackHUDInfo.activeSelf != jetPackEquiped) {
jetpackHUDInfo.SetActive (jetPackEquiped);
}
}
eventOnStateEnabled.Invoke ();
} else {
if (jetpackHUDInfo.activeSelf != jetPackEquiped) {
jetpackHUDInfo.SetActive (jetPackEquiped);
}
eventOnStateDisabled.Invoke ();
if (usingJetpack) {
if (useJetpackAnimation) {
jetPackAnimation [animationName].speed = -1;
jetPackAnimation [animationName].time = 0;
jetPackAnimation.Rewind ();
}
startOrStopJetpack (false);
}
}
if (disableJetpackMeshWhenNotEquipped) {
if (jetpack != null) {
if (jetpack.activeSelf != jetPackEquiped) {
jetpack.SetActive (jetPackEquiped);
}
}
}
if (!state) {
if (previousExternalControllerBehavior != null) {
if (previousExternalControllerBehavior != this) {
previousExternalControllerBehavior.checkIfResumeExternalControllerState ();
}
}
}
}
public void getJetpackFuel (float amount)
{
jetpackFuelAmount += amount;
if (jetpackFuelAmount > jetpackSlider.maxValue) {
jetpackFuelAmount = jetpackSlider.maxValue;
}
updateJetpackUIInfo ();
jetpackSlider.value = jetpackFuelAmount;
}
public float getJetpackFuelAmountToPick ()
{
return jetpackSlider.maxValue - jetpackFuelAmount;
}
public void enableOrDisableJetPackMesh (bool state)
{
if (!jetpackEnabled && state) {
return;
}
bool jetpackMeshState = state;
if (disableJetpackMeshWhenNotEquipped && !jetPackEquiped) {
jetpackMeshState = false;
}
if (jetpack != null) {
if (jetpack.activeSelf != jetpackMeshState) {
jetpack.SetActive (jetpackMeshState);
}
}
}
public void removeJetpackMesh ()
{
if (jetpack != null) {
DestroyImmediate (jetpack);
}
}
public void setUsedByAIState (bool state)
{
usedByAI = state;
}
public void enableOrDisableTurbo (bool state)
{
turboActive = state;
mainPlayerCamera.changeCameraFov (turboActive);
//when the player accelerates his movement in the air, the camera shakes
if (turboActive) {
mainPlayerCamera.setShakeCameraState (true, shakeCameraStateName);
} else {
mainPlayerCamera.setShakeCameraState (false, "");
mainPlayerCamera.stopShakeCamera ();
}
if (turboActive) {
mainPlayerController.setCurrentAirSpeedValue (2);
} else {
mainPlayerController.setCurrentAirSpeedValue (1);
}
}
public void setJetpackEnabledState (bool state)
{
if (jetPackEquiped) {
enableOrDisableJetpack (false);
}
jetpackEnabled = state;
}
public void setOriginalJetpackEnabledState ()
{
setJetpackEnabledState (originalJetpackEnabled);
}
public void setJetpackModePausedState (bool state)
{
if (state) {
if (usingJetpack) {
startOrStopJetpack (false);
}
}
jetpackModePaused = state;
}
//Input Elements
public void inputStartOrStopJetpack (bool state)
{
if (jetPackEquiped && !mainPlayerController.driving && canUseJetpack ()) {
startOrStopJetpack (state);
}
}
public void inputChangeTurboState (bool state)
{
if (jetPackEquiped && usingJetpack && turboEnabled) {
if (state) {
if (playerIsAiming) {
turboActivePreviously = true;
return;
}
} else {
turboActivePreviously = false;
}
enableOrDisableTurbo (state);
}
}
public override void disableExternalControllerState ()
{
enableOrDisableJetpack (false);
}
public override void setCurrentPlayerActionSystemCustomActionCategoryID ()
{
if (behaviorCurrentlyActive) {
if (customActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (customActionCategoryID);
}
} else {
if (regularActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (regularActionCategoryID);
}
}
}
public void setJetpackEnabledStateFromEditor (bool state)
{
setJetpackEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Jetpack System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 78069a5ce99c82e49b3f94deaf3d8608
timeCreated: 1468340135
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/Extra Movements/jetpackSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,470 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class paragliderSystem : externalControllerBehavior
{
[Header ("Main Settings")]
[Space]
public bool paragliderModeEnabled = true;
public float gravityForce = -9.8f;
public float gravityMultiplier;
public float minWaitTimeToActivateParaglider = 0.6f;
public float airSpeed = 25;
public float airControl = 10;
[Space]
[Header ("Extra Force Settings")]
[Space]
public bool addExtraUpForce;
public float extraUpForceAmount = 5;
public bool removeExtraUpForceAfterDelay;
public float delayToRemoveExtraUpForce;
[Space]
[Header ("Animation Settings")]
[Space]
public int regularAirID = -1;
public int paragliderID = 1;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool paragliderModePaused;
public bool paragliderModeActive;
public bool playerIsMoving;
public bool externalForceActive;
public Vector3 externaForceDirection;
public float externalForceAmount;
public bool checkingToActivateParaglider;
public int externalForcesCounter;
public bool useLastTimeParagliderPauseActive;
public float previousGravityForce = -1000;
public float previousGravityMultiplier = -1000;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnStateEnabled;
public UnityEvent eventOnStateDisabled;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public playerCamera mainPlayerCamera;
public Rigidbody mainRigidbody;
public Transform playerTransform;
float lastTimeParagliderPauseActive;
float useLastTimeParagliderPauseActiveDuration;
Coroutine checkingToActivateCoroutine;
bool originalParagliderModeEnabled;
float lastTimeParagliderActive;
void Start ()
{
originalParagliderModeEnabled = paragliderModeEnabled;
}
public override void updateControllerBehavior ()
{
if (paragliderModeActive) {
if ((!mainPlayerController.isPlayerOnFirstPerson () && mainPlayerController.isPlayerAiming ()) ||
mainPlayerController.isPlayerOnGround () ||
mainPlayerController.isSwimModeActive () ||
mainPlayerController.isWallRunningActive () ||
mainPlayerController.isExternalControlBehaviorForAirTypeActive ()) {
enableOrDisableParagliderMode (false);
}
mainPlayerController.setLastTimeFalling ();
Vector3 movementDirection = airSpeed * mainPlayerController.getMoveInputDirection ();
movementDirection += playerTransform.InverseTransformDirection (mainRigidbody.linearVelocity).y * playerTransform.up;
if (addExtraUpForce) {
bool addExtraUpResult = true;
if (removeExtraUpForceAfterDelay) {
if (Time.time > delayToRemoveExtraUpForce + lastTimeParagliderActive) {
addExtraUpResult = false;
}
}
if (addExtraUpResult) {
movementDirection += extraUpForceAmount * playerTransform.up;
}
}
if (externalForceActive) {
movementDirection += externalForceAmount * externaForceDirection;
}
mainPlayerController.setExternalForceOnAir (movementDirection, airControl);
}
}
public override bool isCharacterOnGround ()
{
if (paragliderModeActive) {
return mainPlayerController.isPlayerOnGround ();
}
return true;
}
public override bool isBehaviorActive ()
{
return paragliderModeActive;
}
public void enableOrDisableParagliderMode (bool state)
{
if (showDebugPrint) {
print ("paraglider " + state);
}
if (!paragliderModeEnabled) {
return;
}
if (mainPlayerController.isUseExternalControllerBehaviorPaused ()) {
return;
}
if (paragliderModePaused && state) {
return;
}
if (paragliderModeActive == state) {
return;
}
if (state) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior != null && currentExternalControllerBehavior != this) {
if (canBeActivatedIfOthersBehaviorsActive && checkIfCanEnableBehavior (currentExternalControllerBehavior.behaviorName)) {
currentExternalControllerBehavior.disableExternalControllerState ();
} else {
return;
}
}
}
bool paragliderModeActivePrevioulsy = paragliderModeActive;
paragliderModeActive = state;
bool usingDifferentExternalControllerBehavior = false;
if (showDebugPrint) {
print ("setting state");
}
setBehaviorCurrentlyActiveState (state);
setCurrentPlayerActionSystemCustomActionCategoryID ();
if (paragliderModeActive) {
mainPlayerController.setExternalControllerBehavior (this);
} else {
if (paragliderModeActivePrevioulsy) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior == null || currentExternalControllerBehavior == this) {
mainPlayerController.setExternalControllerBehavior (null);
} else {
usingDifferentExternalControllerBehavior = true;
}
}
}
if (!state) {
if (!usingDifferentExternalControllerBehavior) {
mainPlayerController.setLastTimeFalling ();
}
}
if (state) {
mainPlayerController.setCurrentAirIDValue (paragliderID);
} else {
if (!usingDifferentExternalControllerBehavior) {
mainPlayerController.setCurrentAirIDValue (regularAirID);
}
}
if (paragliderModeActive) {
eventOnStateEnabled.Invoke ();
} else {
eventOnStateDisabled.Invoke ();
}
mainPlayerController.setSlowFallExternallyActiveState (paragliderModeActive);
if (paragliderModeActive) {
if (previousGravityForce == -1000) {
previousGravityForce = mainPlayerController.getGravityForce ();
previousGravityMultiplier = mainPlayerController.getGravityMultiplier ();
if (previousGravityMultiplier > gravityMultiplier) {
mainPlayerController.setGravityMultiplierValue (false, gravityMultiplier);
}
if (previousGravityForce > gravityForce) {
mainPlayerController.setGravityForceValue (false, gravityForce);
}
}
} else {
if (previousGravityForce != -1000) {
mainPlayerController.setGravityMultiplierValue (false, previousGravityMultiplier);
mainPlayerController.setGravityForceValue (false, previousGravityForce);
previousGravityForce = -1000;
previousGravityMultiplier = -1000;
}
}
mainPlayerCamera.stopShakeCamera ();
mainPlayerController.resetOtherInputFields ();
mainPlayerController.disableExternalForceOnAirActive ();
if (!paragliderModeActive) {
if (mainPlayerController.checkIfPlayerOnGroundWithRaycast () || mainPlayerController.isPlayerOnGround ()) {
mainPlayerController.setCheckOnGroungPausedState (false);
mainPlayerController.setPlayerOnGroundState (false);
mainPlayerController.setPlayerOnGroundAnimatorStateOnOverrideOnGroundWithTime (true);
mainPlayerController.disableOverrideOnGroundAnimatorValue ();
mainPlayerController.setPauseResetAnimatorStateFOrGroundAnimatorState (true);
mainPlayerController.setJumpAnimatorIDValue (-9);
mainPlayerController.setPlayerOnGroundState (true);
mainPlayerController.setOnGroundAnimatorIDValue (true);
}
}
lastTimeParagliderActive = Time.time;
}
public override void updateExternalForceActiveState (Vector3 forceDirection, float forceAmount)
{
if (!paragliderModeEnabled) {
return;
}
externaForceDirection = forceDirection;
externalForceAmount = forceAmount;
}
public override void setExternalForceActiveState (bool state)
{
if (!paragliderModeEnabled) {
return;
}
externalForceActive = state;
if (state) {
externalForcesCounter++;
} else {
externalForcesCounter--;
}
if (externalForcesCounter < 0) {
externalForcesCounter = 0;
}
if (externalForcesCounter > 0) {
externalForceActive = true;
} else if (externalForcesCounter == 0) {
externalForceActive = false;
}
}
public void inputToggletParagliderActiveState ()
{
if (paragliderModeActive) {
enableOrDisableParagliderMode (false);
} else {
inputSetParagliderActiveState (!checkingToActivateParaglider);
}
}
public void inputSetParagliderActiveState (bool state)
{
if (!paragliderModeEnabled) {
return;
}
if (mainPlayerController.isPlayerOnGround () ||
mainPlayerController.isPlayerOnFFOrZeroGravityModeOn () ||
mainPlayerController.isWallRunningActive () ||
mainPlayerController.isSwimModeActive () ||
mainPlayerController.isPlayerDriving () ||
mainPlayerController.isExternalControlBehaviorForAirTypeActive ()) {
if (checkingToActivateParaglider) {
stopCheckingToActivateParagliderCoroutine ();
checkingToActivateParaglider = false;
}
return;
}
if (useLastTimeParagliderPauseActive) {
if (Time.time < lastTimeParagliderPauseActive + useLastTimeParagliderPauseActiveDuration) {
return;
} else {
useLastTimeParagliderPauseActive = false;
}
}
checkingToActivateParaglider = state;
if (checkingToActivateParaglider) {
stopCheckingToActivateParagliderCoroutine ();
checkingToActivateCoroutine = StartCoroutine (checkingToActivateParagliderCoroutine ());
} else {
if (paragliderModeActive) {
enableOrDisableParagliderMode (false);
}
stopCheckingToActivateParagliderCoroutine ();
}
}
public void stopCheckingToActivateParagliderCoroutine ()
{
if (checkingToActivateCoroutine != null) {
StopCoroutine (checkingToActivateCoroutine);
}
}
IEnumerator checkingToActivateParagliderCoroutine ()
{
WaitForSeconds delay = new WaitForSeconds (minWaitTimeToActivateParaglider);
yield return delay;
if (checkingToActivateParaglider) {
enableOrDisableParagliderMode (true);
checkingToActivateParaglider = false;
}
}
public void setParagliderModePausedState (bool state)
{
if (state) {
if (paragliderModeActive) {
enableOrDisableParagliderMode (false);
}
}
paragliderModePaused = state;
}
public void setUseLastTimeParagliderPauseActive (float newDuration)
{
useLastTimeParagliderPauseActive = true;
lastTimeParagliderPauseActive = Time.time;
useLastTimeParagliderPauseActiveDuration = newDuration;
}
public void setParagliderModeEnabledState (bool state)
{
if (paragliderModeActive) {
enableOrDisableParagliderMode (false);
}
paragliderModeEnabled = state;
}
public void setOriginalParagliderModeEnabledState ()
{
setParagliderModeEnabledState (originalParagliderModeEnabled);
}
public override void disableExternalControllerState ()
{
if (paragliderModeActive) {
enableOrDisableParagliderMode (false);
}
}
public override void setCurrentPlayerActionSystemCustomActionCategoryID ()
{
if (behaviorCurrentlyActive) {
if (customActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (customActionCategoryID);
}
} else {
if (regularActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (regularActionCategoryID);
}
}
}
public void setParagliderModeEnabledStateFromEditor (bool state)
{
setParagliderModeEnabledState (state);
updateComponent ();
}
void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Paraglider System", gameObject);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: aa96fce354d98d043b355a6baacfc0b3
timeCreated: 1621049163
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/Extra Movements/paragliderSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,544 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class playerSphereModeSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool sphereModeEnabled;
public string defaultVehicleStateName = "Sphere";
[Space]
[Header ("Vehicle Info List Settings")]
[Space]
public List<vehicleInfo> vehicleInfoList = new List<vehicleInfo> ();
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool usingSphereMode;
public bool isExternalVehicleController;
public mainRiderSystem currentRiderSystem;
public Transform currentRiderSystemTransform;
[Space]
public Transform currentObjectToControlTransform;
public GameObject currentObjectToControl;
[Space]
[Header ("Components")]
[Space]
public playerController playerManager;
public gravitySystem gravityManager;
public usingDevicesSystem usingDevicesManager;
public Collider playerCollider;
public overrideElementControlSystem mainOverrideElementControlSystem;
Collider mainVehicleCollider;
GameObject vehicleCamera;
vehicleGravityControl vehicleGravityManager;
bool initialized;
Coroutine updateCoroutine;
vehicleHUDManager currenVehicleHUDManager;
bool currenVehicleHUDManagerLocated;
vehicleInfo currentVehicleInfo;
void stopUpdateCoroutine ()
{
if (updateCoroutine != null) {
StopCoroutine (updateCoroutine);
}
}
IEnumerator updateSystemCoroutine ()
{
var waitTime = new WaitForFixedUpdate ();
while (true) {
updateSystem ();
yield return waitTime;
}
}
void updateSystem ()
{
if (usingSphereMode && currenVehicleHUDManagerLocated) {
if (currenVehicleHUDManager.vehicleIsDestroyed ()) {
stopUpdateCoroutine ();
//setSphereModeActiveState (false);
if (currentVehicleInfo.useEventOnVehicleDestroyed) {
currentVehicleInfo.eventOnVehicleDestroyed.Invoke ();
}
}
}
}
void checkCurrentVehicleInfo ()
{
if (currentVehicleInfo == null || !initialized) {
initialized = true;
setCurrentVehicleInfo (defaultVehicleStateName);
}
}
public void setCurrentVehicleInfo (string newVehicleInfoName)
{
for (int i = 0; i < vehicleInfoList.Count; i++) {
if (vehicleInfoList [i].Name.Equals (newVehicleInfoName)) {
if (currentVehicleInfo != null) {
if (currentObjectToControl != null) {
if (currentVehicleInfo != vehicleInfoList [i]) {
currentObjectToControl = null;
currentRiderSystemTransform = null;
}
}
}
currentVehicleInfo = vehicleInfoList [i];
if (!currentVehicleInfo.isCurrentVehicle) {
if (currentVehicleInfo.useEventOnVehicleInfoState) {
currentVehicleInfo.eventOnVehicleInfoState.Invoke ();
}
}
currentVehicleInfo.isCurrentVehicle = true;
if (showDebugPrint) {
print ("setCurrentVehicleInfo " + newVehicleInfoName);
}
} else {
if (vehicleInfoList [i].isCurrentVehicle) {
setSphereModeActiveState (false);
}
vehicleInfoList [i].isCurrentVehicle = false;
}
}
}
public void toggleSphereModeActiveState ()
{
setSphereModeActiveState (!usingSphereMode);
}
public void setSphereModeActiveState (bool state)
{
if (!sphereModeEnabled) {
return;
}
if (showDebugPrint) {
print ("calling setVehicleState coroutine " + state);
}
if (playerManager.canUseSphereMode) {
StartCoroutine (setVehicleState (state));
}
}
IEnumerator setVehicleState (bool state)
{
checkCurrentVehicleInfo ();
currenVehicleHUDManagerLocated = false;
usingSphereMode = state;
if (showDebugPrint) {
print ("setVehicleState " + state);
}
if (state) {
if (currentVehicleInfo.controlWithOverrideSystem) {
if (currentVehicleInfo.currentVehicleObject != null) {
if (!mainOverrideElementControlSystem.checkIfTemporalObjectOnList (currentVehicleInfo.currentVehicleObject)) {
currentVehicleInfo.currentVehicleObject = null;
}
}
}
if (currentObjectToControl != null) {
currenVehicleHUDManager = currentObjectToControl.GetComponentInChildren<vehicleHUDManager> ();
currenVehicleHUDManagerLocated = currenVehicleHUDManager != null;
if (currenVehicleHUDManagerLocated) {
if (currenVehicleHUDManager.vehicleIsDestroyed ()) {
currentVehicleInfo.currentVehicleObject = null;
currentObjectToControl = null;
currentRiderSystem = null;
if (showDebugPrint) {
print ("current vehicle is destroying, removing to instantiate a new one");
}
currenVehicleHUDManager = null;
currenVehicleHUDManagerLocated = false;
}
}
}
if (currentVehicleInfo.currentVehicleObject == null) {
Vector3 vehiclePosition = Vector3.one * 1000;
if (currentVehicleInfo.adjustVehicleParentToPlayerPosition) {
vehiclePosition = playerManager.transform.position + playerManager.transform.up;
}
currentVehicleInfo.currentVehicleObject = (GameObject)Instantiate (currentVehicleInfo.vehiclePrefab, vehiclePosition, Quaternion.identity);
if (!currentVehicleInfo.currentVehicleObject.activeSelf) {
currentVehicleInfo.currentVehicleObject.SetActive (true);
}
yield return new WaitForSeconds (0.00001f);
getCurrentVehicleComponents ();
if (vehicleGravityManager != null) {
vehicleGravityManager.pauseDownForce (true);
}
currentObjectToControlTransform.gameObject.SetActive (false);
if (mainVehicleCollider != null) {
mainVehicleCollider.enabled = false;
}
yield return new WaitForSeconds (0.00001f);
if (vehicleGravityManager != null) {
vehicleGravityManager.pauseDownForce (false);
}
yield return null;
} else {
getCurrentVehicleComponents ();
yield return null;
}
// if (currentVehicleInfo.currentVehicleObject != null) {
// getCurrentVehicleComponents ();
// }
if (currentObjectToControl != null) {
if (!currentObjectToControlTransform.gameObject.activeSelf) {
if (vehicleGravityManager != null) {
vehicleGravityManager.setCustomNormal (gravityManager.getCurrentNormal ());
}
Vector3 vehiclePosition = playerManager.transform.position + playerManager.transform.up;
currentObjectToControlTransform.position = vehiclePosition;
if (currentVehicleInfo.setVehicleRotationWheGetOn) {
currentObjectToControlTransform.rotation = playerManager.transform.rotation;
}
if (vehicleCamera != null) {
vehicleCamera.transform.position = vehiclePosition;
}
if (isExternalVehicleController) {
if (currentRiderSystemTransform != currentObjectToControlTransform) {
print (currentObjectToControlTransform.name + " " + currentRiderSystemTransform.name);
currentRiderSystemTransform.SetParent (currentObjectToControlTransform);
currentRiderSystemTransform.transform.localPosition = Vector3.zero;
currentRiderSystemTransform.transform.localRotation = Quaternion.identity;
}
}
if (!currentObjectToControlTransform.gameObject.activeSelf) {
currentObjectToControlTransform.gameObject.SetActive (true);
}
if (currentRiderSystem != null) {
currentRiderSystem.setTriggerToDetect (playerCollider);
}
yield return null;
}
stopUpdateCoroutine ();
updateCoroutine = StartCoroutine (updateSystemCoroutine ());
}
} else {
stopUpdateCoroutine ();
if (currentObjectToControl != null) {
if (currentObjectToControlTransform.gameObject.activeSelf) {
if (vehicleCamera != null) {
if (currentVehicleInfo.setVehicleRotationWheGetOn) {
currentObjectToControlTransform.rotation = vehicleCamera.transform.rotation;
}
}
}
}
}
if (currentObjectToControl != null) {
if (currentVehicleInfo.controlWithOverrideSystem) {
if (state) {
mainOverrideElementControlSystem.overrideElementControl (currentObjectToControl);
mainOverrideElementControlSystem.addNewTemporalObject (currentObjectToControl);
} else {
mainOverrideElementControlSystem.inputStopOverrideControl ();
if (mainOverrideElementControlSystem.checkIfTemporalObjectOnList (currentObjectToControl)) {
currentObjectToControlTransform.gameObject.SetActive (false);
}
}
} else {
if (state) {
usingDevicesManager.clearDeviceList ();
usingDevicesManager.addDeviceToList (currentObjectToControl);
usingDevicesManager.setCurrentVehicle (currentObjectToControl);
usingDevicesManager.useCurrentDevice (currentObjectToControl);
usingDevicesManager.setUseDeviceButtonEnabledState (false);
usingDevicesManager.setPauseVehicleGetOffInputState (true);
} else {
if (currentVehicleInfo.currentVehicleObject != null) {
usingDevicesManager.useDevice ();
usingDevicesManager.checkTriggerInfo (mainVehicleCollider, false);
usingDevicesManager.removeCurrentVehicle (currentObjectToControl);
}
if (isExternalVehicleController) {
currentRiderSystemTransform.SetParent (null);
}
currentObjectToControlTransform.gameObject.SetActive (false);
usingDevicesManager.setUseDeviceButtonEnabledState (true);
usingDevicesManager.setPauseVehicleGetOffInputState (false);
}
}
}
if (state) {
if (currentVehicleInfo != null) {
playerManager.enableOrDisableSphereMode (true);
playerManager.setCheckOnGroungPausedState (true);
playerManager.setPlayerOnGroundState (false);
playerManager.setPlayerOnGroundAnimatorStateOnOverrideOnGroundWithTime (false);
playerManager.overrideOnGroundAnimatorValue (0);
playerManager.setPlayerOnGroundAnimatorStateOnOverrideOnGround (false);
playerManager.setOnGroundAnimatorIDValue (false);
currentVehicleInfo.isCurrentVehicle = true;
}
} else {
if (currentVehicleInfo != null) {
if (currentVehicleInfo.isCurrentVehicle) {
currentVehicleInfo.isCurrentVehicle = false;
playerManager.enableOrDisableSphereMode (false);
playerManager.setCheckOnGroungPausedState (false);
playerManager.setPlayerOnGroundState (false);
playerManager.setPlayerOnGroundAnimatorStateOnOverrideOnGroundWithTime (true);
playerManager.disableOverrideOnGroundAnimatorValue ();
playerManager.setPauseResetAnimatorStateFOrGroundAnimatorState (true);
if (playerManager.getCurrentSurfaceBelowPlayer () != null) {
playerManager.setPlayerOnGroundState (true);
playerManager.setOnGroundAnimatorIDValue (true);
}
if (currentVehicleInfo.destroyVehicleOnStopUse) {
StartCoroutine (destroyVehicleObjectCororutine (currentVehicleInfo.currentVehicleObject));
currentVehicleInfo.currentVehicleObject = null;
}
}
}
}
if (currentObjectToControl != null) {
currenVehicleHUDManager = currentObjectToControl.GetComponentInChildren<vehicleHUDManager> ();
currenVehicleHUDManagerLocated = currenVehicleHUDManager != null;
}
}
void getCurrentVehicleComponents ()
{
if (currentVehicleInfo.controlWithOverrideSystem) {
currentObjectToControl = currentVehicleInfo.currentVehicleObject;
currentObjectToControlTransform = currentObjectToControl.transform;
} else {
currentRiderSystem = currentVehicleInfo.currentVehicleObject.GetComponentInChildren<mainRiderSystem> ();
if (currentRiderSystem == null) {
GKCRiderSocketSystem currentGKCRiderSocketSystem = currentVehicleInfo.currentVehicleObject.GetComponentInChildren<GKCRiderSocketSystem> ();
if (currentGKCRiderSocketSystem != null) {
currentRiderSystem = currentGKCRiderSocketSystem.getMainRiderSystem ();
}
}
isExternalVehicleController = currentRiderSystem.isExternalVehicleController;
if (currentRiderSystem != null) {
vehicleGravityManager = currentRiderSystem.getVehicleGravityControl ();
if (isExternalVehicleController) {
currentRiderSystemTransform = currentRiderSystem.transform;
electronicDevice currentElectronicDevice = currentRiderSystem.gameObject.GetComponentInChildren<electronicDevice> ();
if (currentElectronicDevice != null) {
currentElectronicDevice.setPlayerManually (playerManager.gameObject);
}
} else {
currentRiderSystemTransform = null;
}
}
if (currentRiderSystem != null) {
currentRiderSystem.setPlayerVisibleInVehicleState (currentVehicleInfo.playerVisibleInVehicle);
currentRiderSystem.setEjectPlayerWhenDestroyedState (currentVehicleInfo.ejectPlayerWhenDestroyed);
currentRiderSystem.setResetCameraRotationWhenGetOnState (currentVehicleInfo.resetCameraRotationWhenGetOn);
}
if (currentRiderSystem != null) {
currentObjectToControl = currentRiderSystem.getVehicleGameObject ();
currentObjectToControlTransform = currentRiderSystem.getCustomVehicleTransform ();
vehicleCamera = currentRiderSystem.getVehicleCameraGameObject ();
}
mainVehicleCollider = currentObjectToControl.GetComponent<Collider> ();
tutorialActivatorSystem currentTutorialActivatorSystem = currentVehicleInfo.currentVehicleObject.GetComponent<tutorialActivatorSystem> ();
if (currentTutorialActivatorSystem != null) {
currentTutorialActivatorSystem.setTutorialEnabledState (false);
}
}
}
IEnumerator destroyVehicleObjectCororutine (GameObject currentVehicleObject)
{
yield return new WaitForSeconds (0.00001f);
currenVehicleHUDManager = currentVehicleObject.GetComponent<vehicleHUDManager> ();
if (currenVehicleHUDManager != null) {
currenVehicleHUDManager.destroyVehicleAtOnce ();
} else {
Destroy (currentVehicleInfo.currentVehicleObject);
}
}
[System.Serializable]
public class vehicleInfo
{
[Header ("Main Settings")]
[Space]
public string Name;
[Space]
[Header ("Other Settings")]
[Space]
public bool playerVisibleInVehicle;
public bool adjustVehicleParentToPlayerPosition;
public bool ejectPlayerWhenDestroyed = true;
public bool controlWithOverrideSystem;
public bool setVehicleRotationWheGetOn = true;
public bool resetCameraRotationWhenGetOn;
public bool destroyVehicleOnStopUse;
[Space]
[Header ("Debug")]
[Space]
public bool isCurrentVehicle;
public GameObject currentVehicleObject;
[Space]
[Header ("Components Settings")]
[Space]
public GameObject vehiclePrefab;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventOnVehicleInfoState;
public UnityEvent eventOnVehicleInfoState;
public bool useEventOnVehicleDestroyed;
public UnityEvent eventOnVehicleDestroyed;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4accd2f648fb0df43b04c56d06cf4f00
timeCreated: 1554011709
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/Extra Movements/playerSphereModeSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,179 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class portableClimbRopeTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool useDownRaycastDirection;
public LayerMask raycastLayermask;
public float maxRaycastDistance;
public bool adjustRopeEndToAnyDistance;
public bool activateOnStart;
[Space]
[Header ("Other Settings")]
[Space]
public bool checkSurfaceLayer;
public LayerMask layerSurface;
public float raycastRadius;
public bool destroyObjectIfSurfaceNotFound;
public bool checkSurfaceInclination;
public float maxSurfaceInclination;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
[Header ("Components")]
[Space]
public climbRopeTriggerSystem mainClimbRopeTriggerSystem;
public Transform ropePivotTransform;
public Transform customRaycastDirection;
RaycastHit hit;
void Start ()
{
if (activateOnStart) {
activateClimbRopeTrigger ();
}
}
public void activateClimbRopeTrigger ()
{
if (checkSurfaceLayer) {
Collider[] hits = Physics.OverlapSphere (transform.position, raycastRadius);
if (hits.Length <= 0) {
if (destroyObjectIfSurfaceNotFound) {
if (showDebugPrint) {
print ("No surface found on portacle climb rope trigger system, destroy rope");
}
Destroy (gameObject);
}
}
if (checkSurfaceInclination) {
Vector3 rayPosition = transform.position;
for (int i = 0; i < hits.Length; i++) {
Vector3 heading = hits [i].transform.position - rayPosition;
float distance = heading.magnitude;
Vector3 rayDirection = heading / distance;
if (Physics.Raycast (rayPosition, rayDirection, out hit, distance + 1, raycastLayermask)) {
float hitAngle = Vector3.Angle (Vector3.up, hit.normal);
if (showDebugPrint) {
print ("Angle with surface found of " + hitAngle + " degrees");
}
if (Mathf.Abs (hitAngle) > maxSurfaceInclination) {
if (showDebugPrint) {
print ("Surface angle not possible for portacle climb rope trigger system, destroy rope");
}
Destroy (gameObject);
}
}
}
}
}
Vector3 raycastPosition = transform.position;
Vector3 raycastDirection = Vector3.down;
if (!useDownRaycastDirection) {
raycastDirection = customRaycastDirection.forward;
}
float raycastDistance = maxRaycastDistance;
if (adjustRopeEndToAnyDistance) {
raycastDistance = Mathf.Infinity;
}
Vector3 targetPosition = transform.position;
bool surfaceDetected = false;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, raycastLayermask)) {
targetPosition = hit.point;
surfaceDetected = true;
} else {
targetPosition += Vector3.down * maxRaycastDistance;
}
Transform bottomTransform = mainClimbRopeTriggerSystem.bottomTransform;
Transform topTransform = mainClimbRopeTriggerSystem.topTransform;
topTransform.position = transform.position;
bottomTransform.position = targetPosition;
bool scaleDown = true;
if (surfaceDetected) {
if (hit.distance < 3) {
raycastDirection = Vector3.up;
targetPosition = transform.position;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, raycastLayermask)) {
targetPosition = hit.point;
} else {
targetPosition += raycastDirection * maxRaycastDistance;
}
topTransform.position = targetPosition;
scaleDown = false;
}
}
float scaleZ = GKC_Utils.distance (topTransform.position, bottomTransform.position);
float finalScaleValue = scaleZ + (scaleZ * 0.01f) + 0.5f;
float scaleMultiplier = 1;
if (!scaleDown) {
scaleMultiplier = -1;
}
ropePivotTransform.localScale = new Vector3 (1, 1, finalScaleValue * scaleMultiplier);
Vector3 direction = bottomTransform.position - topTransform.position;
direction = direction / direction.magnitude;
ropePivotTransform.rotation = Quaternion.LookRotation (direction);
bottomTransform.position += Vector3.up * 0.5f;
topTransform.position -= Vector3.up * 2;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9f4a8b7843918c04099f60ac19a2af65
timeCreated: 1641680181
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/Extra Movements/portableClimbRopeTriggerSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,163 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class portableWalkOnBalanceTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public LayerMask raycastLayermask;
public float maxRaycastDistance;
public bool adjustEndToAnyDistance;
public bool activateOnStart;
[Space]
[Header ("Other Settings")]
[Space]
public bool checkSurfaceLayer;
public LayerMask layerSurface;
public float raycastRadius;
public bool destroyObjectIfSurfaceNotFound;
public bool checkSurfaceInclination;
public float minSurfaceInclination;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
[Space]
[Header ("Components")]
[Space]
public Transform pivotTransform;
public Transform startTransform;
public Transform endTransform;
RaycastHit hit;
void Start ()
{
if (activateOnStart) {
activateWalkOnBalanceTrigger ();
}
}
public void activateWalkOnBalanceTrigger ()
{
if (checkSurfaceLayer) {
Collider[] hits = Physics.OverlapSphere (transform.position, raycastRadius);
if (hits.Length <= 0) {
if (destroyObjectIfSurfaceNotFound) {
if (showDebugPrint) {
print ("No surface found on portacle walk on balance trigger system, destroy object");
}
Destroy (gameObject);
}
}
if (checkSurfaceInclination) {
Vector3 rayPosition = transform.position;
for (int i = 0; i < hits.Length; i++) {
Vector3 heading = hits [i].transform.position - rayPosition;
float distance = heading.magnitude;
Vector3 rayDirection = heading / distance;
if (Physics.Raycast (rayPosition, rayDirection, out hit, distance + 1, raycastLayermask)) {
float hitAngle = Vector3.Angle (Vector3.up, hit.normal);
if (showDebugPrint) {
print ("Angle with surface found of " + hitAngle + " degrees");
}
if (Mathf.Abs (hitAngle) < minSurfaceInclination) {
if (showDebugPrint) {
print ("Surface angle not possible for portacle walk on balance trigger system, destroy object");
}
Destroy (gameObject);
}
}
}
}
}
Vector3 raycastPosition = transform.position;
Vector3 raycastDirection = transform.forward;
float raycastDistance = maxRaycastDistance;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, raycastLayermask)) {
transform.rotation = Quaternion.LookRotation (hit.normal);
transform.position = hit.point + hit.normal * 0.1f;
transform.eulerAngles = new Vector3 (0, transform.eulerAngles.y, 0);
} else {
Collider[] hits = Physics.OverlapSphere (transform.position, raycastRadius);
bool surfaceLocated = false;
Vector3 rayPosition = transform.position;
for (int i = 0; i < hits.Length; i++) {
if (!surfaceLocated) {
Vector3 heading = hits [i].transform.position - rayPosition;
float distance = heading.magnitude;
Vector3 rayDirection = heading / distance;
if (Physics.Raycast (rayPosition, rayDirection, out hit, distance + 1, raycastLayermask)) {
transform.rotation = Quaternion.LookRotation (hit.normal);
transform.position = hit.point + hit.normal * 0.1f;
surfaceLocated = true;
}
}
}
}
raycastDirection = transform.forward;
raycastPosition = transform.position;
if (adjustEndToAnyDistance) {
raycastDistance = Mathf.Infinity;
}
Vector3 targetPosition = transform.position;
if (Physics.Raycast (raycastPosition, raycastDirection, out hit, raycastDistance, raycastLayermask)) {
targetPosition = hit.point;
} else {
targetPosition += transform.forward * maxRaycastDistance;
}
startTransform.position = transform.position;
endTransform.position = targetPosition;
float scaleZ = GKC_Utils.distance (startTransform.position, endTransform.position);
float finalScaleValue = scaleZ + (scaleZ * 0.01f) + 0.5f;
pivotTransform.localScale = new Vector3 (1, 1, finalScaleValue);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2a9e034611ec7424295b423ccaca2874
timeCreated: 1643734958
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/Extra Movements/portableWalkOnBalanceTriggerSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,891 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class railSystem : externalControllerBehavior
{
[Header ("Main Settings")]
[Space]
public bool railSystemEnabled = true;
public float lookDirectionSpeed;
public float resetPlayerRotationSpeed = 5;
public float adjustPlayerToRailSpeed = 5;
[Space]
[Header ("Reverse Direction Settings")]
[Space]
public bool canChangeDirectionEnabled;
public float minWaitToChangeDirection = 0.8f;
public float delayToReverseDirection = 1;
public float delayToResumeMovementOnReverseDirection = 0.5f;
public bool reduceSlideSpeedOnReversingDirection;
public float reduceSlideSpeedOnReversingDirectionMultiplier = 0.2f;
[Space]
[Header ("Physics Settings")]
[Space]
public bool useForceMode;
public ForceMode railForceMode;
public bool turboEnabled;
public float turboSpeed;
public float speedOnAimMultiplier;
[Space]
[Header ("Speed Settings")]
[Space]
public bool adjustSpeedBasedOnInclination;
public float speedMultiplierOnInclinationUp;
public float speedMultiplierOnInclinationDown;
public float minInclinationDifferenceToAffectSpeed;
public float speedMultiplierOnInclinationLerp;
[Space]
[Header ("Jump Settings")]
[Space]
public bool canJumpEnabled;
public Vector3 impulseOnJump;
public Vector3 endOfSurfaceImpulse;
public float maxVelocityChangeOnJump;
[Space]
[Header ("Third Person Settings")]
[Space]
public int actionID = 08632946;
public string externalControlleBehaviorActiveAnimatorName = "External Behavior Active";
public string actionIDAnimatorName = "Action ID";
public string horizontalAnimatorName = "Horizontal Action";
public float inputLerpSpeed = 3;
[Space]
[Header ("Third Person Camera State Settings")]
[Space]
public bool setNewCameraStateOnThirdPerson;
public string newCameraStateOnThirdPerson;
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool movementOnRailPausedDebug;
public bool railSystemActive;
public float bezierDuration;
public bool turboActive;
public Vector3 targetDirection;
public BezierSpline currentSpline;
public bool movingForward;
public bool adjustingPlayerToRail;
public float progress = 0;
public float progressTarget = 0;
public bool playerAiming;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventOnStateEnabled;
public UnityEvent eventOnStateDisabled;
public UnityEvent eventBeforeActivatingState;
public UnityEvent eventBeforeDeactivatingState;
public bool useEventUseTurbo;
public UnityEvent eventOnStarTurbo;
public UnityEvent eventOnEndTurbo;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public Animator mainAnimator;
public playerCamera mainPlayerCamera;
public Transform playerTransform;
public Transform playerCameraTransform;
public Rigidbody mainRigidbody;
public headTrack mainHeadTrack;
float currentAimSpeedMultipler;
bool canUseTurboPausedState;
int externalControlleBehaviorActiveAnimatorID;
int actionIDAnimatorID;
int horizontalAnimatorID;
bool isFirstPersonActive;
string previousCameraState = "";
bool turnAndForwardAnimatorValuesPaused;
Coroutine adjustPlayerToRailCoroutine;
Coroutine resetPlayerCoroutine;
Vector3 lookDirection;
float currentInclinationSpeed;
bool resetCameraShakeActive;
float lastTimeDirectionChanged;
float lastTimeReverseMovementDirectionInput;
bool originalCanChangeDirectionEnabled;
bool activateReverseDirectionActive;
float reverseDirectionValue;
void Start ()
{
externalControlleBehaviorActiveAnimatorID = Animator.StringToHash (externalControlleBehaviorActiveAnimatorName);
actionIDAnimatorID = Animator.StringToHash (actionIDAnimatorName);
horizontalAnimatorID = Animator.StringToHash (horizontalAnimatorName);
originalCanChangeDirectionEnabled = canChangeDirectionEnabled;
if (playerCameraTransform == null) {
playerCameraTransform = mainPlayerCamera.transform;
}
}
public override void updateControllerBehavior ()
{
if (railSystemActive && !movementOnRailPausedDebug) {
if (!adjustingPlayerToRail) {
bool targetReached = false;
if (mainPlayerController.isPlayerRunning ()) {
if (!turboActive) {
enableOrDisableTurbo (true);
}
} else {
if (turboActive) {
enableOrDisableTurbo (false);
}
}
int slidingAnimatorValue = 0;
float currentSpeed = bezierDuration;
if (turboActive) {
slidingAnimatorValue = 1;
currentSpeed /= turboSpeed;
}
if (adjustSpeedBasedOnInclination) {
lookDirection = currentSpline.GetDirection (progress);
Vector3 currentNormal = mainPlayerController.getCurrentNormal ();
float angle = Vector3.SignedAngle (playerTransform.up, currentNormal, playerTransform.right);
if (Mathf.Abs (angle) > minInclinationDifferenceToAffectSpeed) {
if (angle < 0) {
currentInclinationSpeed = Mathf.Lerp (currentInclinationSpeed, speedMultiplierOnInclinationDown, Time.deltaTime * speedMultiplierOnInclinationLerp);
} else {
currentInclinationSpeed = Mathf.Lerp (currentInclinationSpeed, speedMultiplierOnInclinationUp, Time.deltaTime * speedMultiplierOnInclinationLerp);
}
} else {
currentInclinationSpeed = Mathf.Lerp (currentInclinationSpeed, 1, Time.deltaTime * speedMultiplierOnInclinationLerp);
}
currentSpeed *= currentInclinationSpeed;
}
bool canRotatePlayerResult = true;
currentAimSpeedMultipler = 1;
if (!mainPlayerController.isPlayerOnFirstPerson () &&
(mainPlayerController.isPlayerAiming () || mainPlayerController.isUsingFreeFireMode ()) &&
!mainPlayerController.isCheckToKeepWeaponAfterAimingWeaponFromShooting ()) {
currentAimSpeedMultipler = speedOnAimMultiplier;
if (!turnAndForwardAnimatorValuesPaused) {
mainPlayerController.setTurnAndForwardAnimatorValuesPausedState (true);
mainPlayerController.setRotateInCameraDirectionOnAirOnExternalActionActiveState (true);
turnAndForwardAnimatorValuesPaused = true;
}
canRotatePlayerResult = false;
if (Time.time > mainPlayerController.getLastTimeFiring () + 0.2f) {
if (resetCameraShakeActive) {
mainPlayerCamera.stopAllHeadbobMovements ();
resetCameraShakeActive = false;
}
} else {
resetCameraShakeActive = true;
}
} else {
if (turnAndForwardAnimatorValuesPaused) {
mainPlayerController.setTurnAndForwardAnimatorValuesPausedState (false);
mainPlayerController.setRotateInCameraDirectionOnAirOnExternalActionActiveState (false);
turnAndForwardAnimatorValuesPaused = false;
mainPlayerCamera.stopAllHeadbobMovements ();
}
}
if (canChangeDirectionEnabled && canRotatePlayerResult) {
Vector2 rawMovementAxis = mainPlayerController.getRawAxisValues ();
if (rawMovementAxis != Vector2.zero) {
Vector3 movementDirection = rawMovementAxis.y * mainPlayerController.getCurrentForwardDirection () +
rawMovementAxis.x * mainPlayerController.getCurrentRightDirection ();
float directionAngle = Vector3.SignedAngle (movementDirection, playerTransform.forward, playerTransform.up);
if (Mathf.Abs (directionAngle) > 90) {
if (movingForward) {
if (Time.time > minWaitToChangeDirection + lastTimeDirectionChanged) {
reverseDirectionValue = -1;
// calculateMovementDirection (-1);
lastTimeReverseMovementDirectionInput = Time.time;
activateReverseDirectionActive = true;
}
} else {
if (Time.time > minWaitToChangeDirection + lastTimeDirectionChanged) {
reverseDirectionValue = 1;
// calculateMovementDirection (1);
lastTimeReverseMovementDirectionInput = Time.time;
activateReverseDirectionActive = true;
}
}
}
}
}
if (activateReverseDirectionActive) {
if (Time.time > delayToReverseDirection + lastTimeReverseMovementDirectionInput) {
activateReverseDirectionActive = false;
calculateMovementDirection (reverseDirectionValue);
}
}
bool canMove = true;
if (lastTimeReverseMovementDirectionInput > 0) {
if (Time.time < lastTimeReverseMovementDirectionInput + delayToResumeMovementOnReverseDirection) {
canMove = false;
slidingAnimatorValue = 0;
if (reduceSlideSpeedOnReversingDirection) {
currentSpeed *= reduceSlideSpeedOnReversingDirectionMultiplier;
canMove = true;
}
} else {
lastTimeReverseMovementDirectionInput = 0;
}
}
mainAnimator.SetFloat (horizontalAnimatorID, slidingAnimatorValue, inputLerpSpeed, Time.fixedDeltaTime);
float currentProgress = 0;
if (canMove) {
currentProgress = Time.deltaTime / (currentSpeed * currentAimSpeedMultipler);
}
if (movingForward) {
progress += currentProgress;
} else {
progress -= currentProgress;
}
Vector3 position = currentSpline.GetPoint (progress);
playerTransform.position = position;
if (mainPlayerCamera.isFullBodyAwarenessActive ()) {
playerCameraTransform.position = position;
}
lookDirection = currentSpline.GetDirection (progress);
if (!movingForward) {
lookDirection = -lookDirection;
}
if (canRotatePlayerResult) {
Quaternion targetRotation = Quaternion.LookRotation (lookDirection);
if (mainPlayerCamera.isFullBodyAwarenessActive ()) {
playerCameraTransform.rotation = Quaternion.Lerp (playerCameraTransform.rotation, targetRotation, Time.fixedDeltaTime * lookDirectionSpeed);
} else {
playerTransform.rotation = Quaternion.Lerp (playerTransform.rotation, targetRotation, Time.fixedDeltaTime * lookDirectionSpeed);
}
}
if (movingForward) {
if (progress > progressTarget) {
targetReached = true;
}
} else {
if (progress < progressTarget) {
targetReached = true;
}
}
if (targetReached) {
stopRail ();
}
}
}
}
public override void setExtraImpulseForce (Vector3 forceAmount, bool useCameraDirection)
{
setImpulseForce (forceAmount, useCameraDirection);
}
public void setImpulseForce (Vector3 forceAmount, bool useCameraDirection)
{
Vector3 impulseForce = forceAmount;
Vector3 velocityChange = Vector3.zero;
if (maxVelocityChangeOnJump > 0) {
velocityChange = impulseForce - mainRigidbody.linearVelocity;
velocityChange = Vector3.ClampMagnitude (velocityChange, maxVelocityChangeOnJump);
} else {
velocityChange = impulseForce;
}
mainPlayerController.setVelocityChangeValue (impulseForce);
mainRigidbody.AddForce (impulseForce, ForceMode.VelocityChange);
}
public override void setJumpActiveForExternalForce ()
{
setJumpActive (impulseOnJump);
}
public void setJumpActive (Vector3 newImpulseOnJumpAmount)
{
if (railSystemActive) {
setRailSystemActivestate (false);
Vector3 totalForce = newImpulseOnJumpAmount.y * playerTransform.up + newImpulseOnJumpAmount.z * playerTransform.forward;
mainPlayerController.useJumpPlatform (totalForce, ForceMode.Impulse);
}
}
public override void setExternalForceActiveState (bool state)
{
setRailSystemActivestate (state);
}
public void setRailSystemActivestate (bool state)
{
if (!railSystemEnabled) {
return;
}
if (railSystemActive == state) {
return;
}
if (mainPlayerController.isUseExternalControllerBehaviorPaused ()) {
return;
}
if (state && mainPlayerController.isPlayerDead ()) {
return;
}
if (state) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior != null && currentExternalControllerBehavior != this) {
if (canBeActivatedIfOthersBehaviorsActive && checkIfCanEnableBehavior (currentExternalControllerBehavior.behaviorName)) {
currentExternalControllerBehavior.disableExternalControllerState ();
} else {
return;
}
}
}
bool modeActivePrevioulsy = railSystemActive;
railSystemActive = state;
setBehaviorCurrentlyActiveState (state);
setCurrentPlayerActionSystemCustomActionCategoryID ();
if (showDebugPrint) {
print ("Setting state as " + railSystemActive);
}
mainPlayerController.setExternalControlBehaviorForAirTypeActiveState (state);
if (state) {
mainPlayerController.setCheckOnGroungPausedState (true);
mainPlayerController.setPlayerOnGroundState (false);
mainPlayerController.setPlayerOnGroundAnimatorStateOnOverrideOnGroundWithTime (false);
mainPlayerController.overrideOnGroundAnimatorValue (0);
mainPlayerController.setPlayerOnGroundAnimatorStateOnOverrideOnGround (false);
mainPlayerController.setOnGroundAnimatorIDValue (false);
} else {
mainPlayerController.setCheckOnGroungPausedState (false);
mainPlayerController.setPlayerOnGroundState (false);
mainPlayerController.setPlayerOnGroundAnimatorStateOnOverrideOnGroundWithTime (true);
mainPlayerController.disableOverrideOnGroundAnimatorValue ();
mainPlayerController.setPauseResetAnimatorStateFOrGroundAnimatorState (true);
mainPlayerController.setOnGroundAnimatorIDValue (false);
}
mainPlayerController.setUpdate2_5dClampedPositionPausedState (state);
mainPlayerController.setFootStepManagerState (state);
mainPlayerController.setAddExtraRotationPausedState (state);
mainPlayerController.setIgnoreExternalActionsActiveState (state);
if (railSystemActive) {
mainPlayerController.setExternalControllerBehavior (this);
} else {
if (modeActivePrevioulsy) {
externalControllerBehavior currentExternalControllerBehavior = mainPlayerController.getCurrentExternalControllerBehavior ();
if (currentExternalControllerBehavior == null || currentExternalControllerBehavior == this) {
mainPlayerController.setExternalControllerBehavior (null);
}
if (playerTransform.up != mainPlayerController.getCurrentNormal ()) {
resetPlayerRotation ();
}
}
}
if (state) {
eventBeforeActivatingState.Invoke ();
} else {
eventBeforeDeactivatingState.Invoke ();
}
mainPlayerController.setFallDamageCheckPausedState (state);
if (railSystemActive) {
eventOnStateEnabled.Invoke ();
} else {
eventOnStateDisabled.Invoke ();
if (turboActive) {
enableOrDisableTurbo (false);
}
}
mainHeadTrack.setExternalHeadTrackPauseActiveState (state);
mainPlayerController.stopShakeCamera ();
mainPlayerCamera.setPausePlayerCameraViewChangeState (state);
mainPlayerController.setLastTimeFalling ();
if (state) {
calculateMovementDirection (0);
} else {
stopAdjustPlayerToRailOnStartCoroutine ();
}
if (state) {
mainAnimator.SetInteger (actionIDAnimatorID, actionID);
mainAnimator.SetBool (externalControlleBehaviorActiveAnimatorID, state);
} else {
mainAnimator.SetBool (externalControlleBehaviorActiveAnimatorID, state);
mainAnimator.SetInteger (actionIDAnimatorID, 0);
}
isFirstPersonActive = mainPlayerController.isPlayerOnFirstPerson ();
if (setNewCameraStateOnThirdPerson && !isFirstPersonActive) {
if (state) {
previousCameraState = mainPlayerCamera.getCurrentStateName ();
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (newCameraStateOnThirdPerson);
} else {
if (previousCameraState != "") {
if (previousCameraState != newCameraStateOnThirdPerson) {
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (previousCameraState);
}
previousCameraState = "";
}
}
}
if (turnAndForwardAnimatorValuesPaused) {
mainPlayerController.setTurnAndForwardAnimatorValuesPausedState (false);
mainPlayerController.setRotateInCameraDirectionOnAirOnExternalActionActiveState (false);
turnAndForwardAnimatorValuesPaused = false;
}
currentInclinationSpeed = 1;
playerAiming = false;
resetCameraShakeActive = false;
}
void calculateMovementDirection (float inputDirection)
{
progress = 0;
progressTarget = 1;
Vector3 playerPosition = currentSpline.FindNearestPointTo (playerTransform.position, 100, 30);
adjustPlayerToRailOnStart (playerPosition);
float step = currentSpline.AccuracyToStepSize (100);
float minDistance = Mathf.Infinity;
for (float i = 0f; i < 1f; i += step) {
Vector3 thisPoint = currentSpline.GetPoint (i);
float thisDistance = (playerPosition - thisPoint).sqrMagnitude;
if (thisDistance < minDistance) {
minDistance = thisDistance;
progress = i;
}
}
lookDirection = currentSpline.GetDirection (progress);
float angle = Vector3.SignedAngle (playerTransform.forward, lookDirection, playerTransform.up);
movingForward = false;
if (Mathf.Abs (angle) < 90) {
movingForward = true;
}
if (showDebugPrint) {
print (movingForward + " " + progress + " " + angle);
}
if (inputDirection != 0) {
if (inputDirection > 0) {
movingForward = true;
} else {
movingForward = false;
}
}
if (!movingForward) {
progressTarget = 0;
}
lastTimeDirectionChanged = Time.time;
lastTimeReverseMovementDirectionInput = 0;
activateReverseDirectionActive = false;
}
public override void setExternalForceEnabledState (bool state)
{
setRailEnabledState (state);
}
public void setRailEnabledState (bool state)
{
if (!state) {
setRailSystemActivestate (false);
}
railSystemEnabled = state;
}
public void enableOrDisableTurbo (bool state)
{
if (turboActive == state) {
return;
}
if (state && canUseTurboPausedState) {
return;
}
turboActive = state;
if (useEventUseTurbo) {
if (state) {
eventOnStarTurbo.Invoke ();
} else {
eventOnEndTurbo.Invoke ();
}
}
}
public void setCanUseTurboPausedState (bool state)
{
if (!state && turboActive) {
enableOrDisableTurbo (false);
}
canUseTurboPausedState = state;
}
public override void disableExternalControllerState ()
{
setRailSystemActivestate (false);
}
public void inputChangeTurboState (bool state)
{
if (railSystemActive && turboEnabled) {
enableOrDisableTurbo (state);
}
}
public void setCanChangeDirectionEnabledState (bool state)
{
canChangeDirectionEnabled = state;
}
public void setOriginalCanChangeDirectionEnabled ()
{
setCanChangeDirectionEnabledState (originalCanChangeDirectionEnabled);
}
public void setCurrentSpline (BezierSpline newSpline)
{
currentSpline = newSpline;
}
public void setCurrentBezierDuration (float newValue)
{
bezierDuration = newValue;
}
void stopRail ()
{
Vector3 totalForce = Vector3.zero;
totalForce = playerTransform.forward * endOfSurfaceImpulse.z + playerTransform.up * endOfSurfaceImpulse.y;
setRailSystemActivestate (false);
setImpulseForce (totalForce, false);
}
public void adjustPlayerToRailOnStart (Vector3 initialPosition)
{
stopResetPlayerRotationCoroutine ();
adjustPlayerToRailCoroutine = StartCoroutine (adjustPlayerToRailOnStartCoroutine (initialPosition));
}
void stopAdjustPlayerToRailOnStartCoroutine ()
{
if (adjustPlayerToRailCoroutine != null) {
StopCoroutine (adjustPlayerToRailCoroutine);
}
adjustingPlayerToRail = false;
}
IEnumerator adjustPlayerToRailOnStartCoroutine (Vector3 initialPosition)
{
adjustingPlayerToRail = true;
float dist = GKC_Utils.distance (playerTransform.position, initialPosition);
float duration = dist / adjustPlayerToRailSpeed;
float t = 0;
Vector3 pos = initialPosition;
float movementTimer = 0;
bool targetReached = false;
while (!targetReached) {
t += Time.deltaTime / duration;
playerTransform.position = Vector3.Slerp (playerTransform.position, pos, t);
movementTimer += Time.deltaTime;
if (GKC_Utils.distance (playerTransform.position, pos) < 0.01f || movementTimer > (duration + 1)) {
targetReached = true;
}
yield return null;
}
adjustingPlayerToRail = false;
}
public void resetPlayerRotation ()
{
stopResetPlayerRotationCoroutine ();
resetPlayerCoroutine = StartCoroutine (resetPlayerRotationCoroutine ());
}
void stopResetPlayerRotationCoroutine ()
{
if (resetPlayerCoroutine != null) {
StopCoroutine (resetPlayerCoroutine);
}
}
IEnumerator resetPlayerRotationCoroutine ()
{
float movementTimer = 0;
float t = 0;
float duration = 1;
float angleDifference = 0;
Vector3 currentNormal = mainPlayerController.getCurrentNormal ();
bool isFullBodyAwarenessActive = mainPlayerCamera.isFullBodyAwarenessActive ();
Transform objectToRotate = playerTransform;
if (isFullBodyAwarenessActive) {
objectToRotate = playerCameraTransform;
}
Quaternion currentPlayerRotation = objectToRotate.rotation;
Vector3 currentPlayerForward = Vector3.Cross (objectToRotate.right, currentNormal);
Quaternion playerTargetRotation = Quaternion.LookRotation (currentPlayerForward, currentNormal);
bool targetReached = false;
while (!targetReached) {
t += (Time.deltaTime / duration) * resetPlayerRotationSpeed;
objectToRotate.rotation = Quaternion.Slerp (objectToRotate.rotation, playerTargetRotation, t);
angleDifference = Quaternion.Angle (objectToRotate.rotation, playerTargetRotation);
movementTimer += Time.deltaTime;
if (angleDifference < 0.01f || movementTimer > (duration + 1)) {
targetReached = true;
}
yield return null;
}
}
public override void setCurrentPlayerActionSystemCustomActionCategoryID ()
{
if (behaviorCurrentlyActive) {
if (customActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (customActionCategoryID);
}
} else {
if (regularActionCategoryID > -1) {
mainPlayerController.setCurrentCustomActionCategoryID (regularActionCategoryID);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2a02a143ff2ffb8449eaf9418cf4ab0c
timeCreated: 1639204783
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/Extra Movements/railSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,151 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class railTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool railZoneActive = true;
public float bezierDuration;
public BezierSpline railSpline;
public bool checkOnTriggerEnter = true;
public bool checkOnTriggerExit = true;
[Space]
[Header ("Reverse Direction Settings")]
[Space]
public bool setCanChangeDirectionEnabled;
public bool canChangeDirectionEnabled;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEvents;
public bool useRemoteEventOnStart;
public List<string> remoteEventNameListOnStart = new List<string> ();
public bool useRemoteEventOnEnd;
public List<string> remoteEventNameListOnEnd = new List<string> ();
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!railZoneActive) {
return;
}
if (isEnter) {
if (!checkOnTriggerEnter) {
return;
}
} else {
if (!checkOnTriggerExit) {
return;
}
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior railExternalControllerBehavior = currentPlayerComponentsManager.getRailExternalControllerBehavior ();
if (railExternalControllerBehavior != null) {
railSystem currentRailSystem = railExternalControllerBehavior.GetComponent<railSystem> ();
currentRailSystem.setCurrentSpline (railSpline);
currentRailSystem.setCurrentBezierDuration (bezierDuration);
currentRailSystem.setRailSystemActivestate (true);
checkRemoteEvents (true, currentPlayer);
if (setCanChangeDirectionEnabled) {
currentRailSystem.setCanChangeDirectionEnabledState (canChangeDirectionEnabled);
}
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior railExternalControllerBehavior = currentPlayerComponentsManager.getRailExternalControllerBehavior ();
if (railExternalControllerBehavior != null) {
railSystem currentRailSystem = railExternalControllerBehavior.GetComponent<railSystem> ();
currentRailSystem.setRailSystemActivestate (false);
currentRailSystem.setCurrentSpline (null);
checkRemoteEvents (false, currentPlayer);
if (setCanChangeDirectionEnabled) {
currentRailSystem.setOriginalCanChangeDirectionEnabled ();
}
}
}
}
}
void checkRemoteEvents (bool state, GameObject objectToCheck)
{
if (!useRemoteEvents) {
return;
}
if (state) {
if (useRemoteEventOnStart) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnStart.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnStart [i]);
}
}
}
} else {
if (useRemoteEventOnEnd) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnEnd.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnEnd [i]);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c35ab1a59c4084b4995f5ba5ca223d41
timeCreated: 1639204991
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/Extra Movements/railTriggerSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,198 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class rollOnLandingSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool rollOnlandingEnabled = true;
public float rollOnLandingCheckDuration;
public float eventsOnRollLandingDelay;
public float distanceFromGroundToActivateRollOnLanding = 1;
public float minWaitToActivateRollOnLandingInput = 0.5f;
public LayerMask raycastLayermask;
public bool useMaxTimeOnAirToActivateRollOnLanding;
public float maxTimeOnAirToActivateRollOnLanding;
[Space]
[Header ("Debug")]
[Space]
public bool rollOnLandingCheckActive;
public bool showDebugPrint;
[Space]
[Header ("Events Settings")]
[Space]
public UnityEvent eventsOnRollOnLandingThirdPerson;
public UnityEvent eventsOnRollOnLandingFirstPerson;
[Space]
[Header ("Components")]
[Space]
public playerController mainPlayerController;
public Transform playerTransform;
Coroutine landingCoroutine;
float lastTimeRollOnLandingActive;
bool eventsActivated;
float lastTimeRollOnLandingInputActive;
bool cancelCheckRollOnLandingOnceActive;
float lastTimeCancelCheckRoll;
public void setCancelCheckRollOnLandingOnceActive (bool state)
{
cancelCheckRollOnLandingOnceActive = state;
lastTimeCancelCheckRoll = Time.time;
}
public void inputActivateRollOnLanding ()
{
// print (cancelCheckRollOnLandingOnceActive + " " + (Time.time) + " " + (lastTimeCancelCheckRoll + 0.7f));
if (cancelCheckRollOnLandingOnceActive) {
if (Time.time > lastTimeCancelCheckRoll + 0.7f) {
cancelCheckRollOnLandingOnceActive = false;
} else {
return;
}
}
if (!rollOnlandingEnabled) {
return;
}
if (mainPlayerController.isPlayerOnGround ()) {
return;
}
if (Time.time < minWaitToActivateRollOnLandingInput + lastTimeRollOnLandingInputActive) {
return;
}
stopActivateRollOnLandingCoroutine ();
bool canActivateRollOnLanding = true;
if (useMaxTimeOnAirToActivateRollOnLanding) {
float totalTimeOnAir = Mathf.Abs (Time.time - mainPlayerController.getLastTimeFalling ());
if (showDebugPrint) {
print ("Current time on air " + totalTimeOnAir);
}
if (totalTimeOnAir > maxTimeOnAirToActivateRollOnLanding) {
canActivateRollOnLanding = false;
if (showDebugPrint) {
print ("Too much time on air, can't activate roll on landing");
}
}
}
if (mainPlayerController.isFlyingActive () ||
mainPlayerController.isPlayerOnFreeFloatingMode ()) {
canActivateRollOnLanding = false;
if (showDebugPrint) {
print ("can't activate roll on landing on fly mode, or flotaing mode");
}
}
if (canActivateRollOnLanding) {
landingCoroutine = StartCoroutine (activateRollOnLandingCoroutine ());
lastTimeRollOnLandingInputActive = Time.time;
}
}
public void inputDeactivateRollOnLanding ()
{
if (!rollOnlandingEnabled) {
return;
}
if (mainPlayerController.isPlayerOnGround ()) {
return;
}
stopActivateRollOnLandingCoroutine ();
}
void stopActivateRollOnLandingCoroutine ()
{
if (landingCoroutine != null) {
StopCoroutine (landingCoroutine);
}
if (rollOnLandingCheckActive) {
mainPlayerController.setCheckFallStatePausedState (false);
rollOnLandingCheckActive = false;
}
}
IEnumerator activateRollOnLandingCoroutine ()
{
rollOnLandingCheckActive = true;
lastTimeRollOnLandingActive = Time.time;
eventsActivated = false;
mainPlayerController.setCheckFallStatePausedState (true);
bool targetReached = false;
while (!targetReached) {
if (Time.time > lastTimeRollOnLandingActive + rollOnLandingCheckDuration) {
targetReached = true;
} else {
if (!eventsActivated) {
if (Physics.Raycast (playerTransform.position, -playerTransform.up, distanceFromGroundToActivateRollOnLanding, raycastLayermask)) {
if (Time.time > lastTimeRollOnLandingActive + eventsOnRollLandingDelay) {
eventsActivated = true;
if (showDebugPrint) {
print ("Activate roll on landing");
}
if (mainPlayerController.isPlayerOnFirstPerson ()) {
eventsOnRollOnLandingFirstPerson.Invoke ();
} else {
eventsOnRollOnLandingThirdPerson.Invoke ();
}
}
}
}
}
yield return null;
}
mainPlayerController.setCheckFallStatePausedState (false);
rollOnLandingCheckActive = false;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 07d80340cb5235c4e8aacae0bf6ff4bf
timeCreated: 1626090105
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/Extra Movements/rollOnLandingSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class simpleWaypointSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public List<Transform> wayPoints = new List<Transform> ();
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
public Color gizmoLabelColor = Color.black;
public float gizmoRadius;
public List<Transform> getWayPoints ()
{
return wayPoints;
}
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
for (int i = 0; i < wayPoints.Count; i++) {
if (wayPoints [i] != null) {
Gizmos.color = Color.yellow;
Gizmos.DrawSphere (wayPoints [i].position, gizmoRadius);
if (i + 1 < wayPoints.Count && wayPoints [i + 1] != null) {
Gizmos.color = Color.white;
Gizmos.DrawLine (wayPoints [i].position, wayPoints [i + 1].position);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b54a005b5cb9d4945b0024e7888dfafe
timeCreated: 1641103010
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/Extra Movements/simpleWaypointSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 5ec6f7b00092b254ca0a769cc1887cb3
timeCreated: 1630724656
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/Extra Movements/slideSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,137 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class slideZoneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool slideZoneActive = true;
public float slideSpeedMultiplier = 1;
public bool setEnterStateActive = true;
public bool setExitStateActive = true;
public bool justUpdateSlideTransform;
[Space]
[Header ("Jump Settings")]
[Space]
public bool justActivateJumpStateOnSlide;
public Vector3 impulseOnJump;
[Space]
[Header ("Gravity Settings")]
[Space]
public bool justSetAdhereToSurfacesActiveState;
public bool adhereToSurfacesActiveState;
public bool setResetGravityDirectionOnSlideExitEnabledState;
public bool resetGravityDirectionOnSlideExitEnabledState;
[Space]
[Header ("Components")]
[Space]
public Transform slideTransform;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!slideZoneActive) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
if (!setEnterStateActive) {
return;
}
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior slideExternalControllerBehavior = currentPlayerComponentsManager.getSlideExternalControllerBehavior ();
if (slideExternalControllerBehavior != null) {
slideSystem currentSlideSystem = slideExternalControllerBehavior.GetComponent<slideSystem> ();
if (setResetGravityDirectionOnSlideExitEnabledState) {
currentSlideSystem.setResetGravityDirectionOnSlideExitEnabledState (resetGravityDirectionOnSlideExitEnabledState);
}
if (justActivateJumpStateOnSlide) {
currentSlideSystem.setJumpActive (impulseOnJump);
return;
}
if (justSetAdhereToSurfacesActiveState) {
currentSlideSystem.setAdhereToSurfacesActiveState (adhereToSurfacesActiveState);
return;
}
currentSlideSystem.setCurrentSlideTransform (slideTransform);
if (justUpdateSlideTransform) {
return;
}
currentSlideSystem.setSlideSpeedMultiplier (slideSpeedMultiplier);
currentSlideSystem.setCheckIfDetectSlideActiveState (true, true);
}
}
} else {
if (!setExitStateActive) {
return;
}
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior slideExternalControllerBehavior = currentPlayerComponentsManager.getSlideExternalControllerBehavior ();
if (slideExternalControllerBehavior != null) {
slideSystem currentSlideSystem = slideExternalControllerBehavior.GetComponent<slideSystem> ();
currentSlideSystem.setCheckIfDetectSlideActiveState (false, false);
currentSlideSystem.setCurrentSlideTransform (null);
// if (setResetGravityDirectionOnSlideExitEnabledState) {
// currentSlideSystem.setOriginalResetGravityDirectionOnSlideExitEnabled ();
// }
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: ec1334c27d138374ca0506fce9029fb6
timeCreated: 1630727393
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/Extra Movements/slideZoneSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c707040a722187c4fb2cbc84dd8ed5ce
timeCreated: 1627607236
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/Extra Movements/swimSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,303 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class swimTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool swimZoneActive = true;
public bool updateSurfaceTransformDynamically;
[Space]
[Header ("Vehicle Settings")]
[Space]
public bool checkVehiclesOnEnteringWater;
public bool disableVehiclesInteractionOnEnterWater;
public bool ejectPassengersOnVehicleOnEnterWater;
public bool explodeVehiclesAfterXTime;
public float timeToExplodeVehiclesAfterXTime;
public bool setVehicleGravityForce;
public float newVehicleGravityForce;
public bool reduceVehicleSpeedOnEnterWater;
public float reducedVehicleSpeedMultiplier;
public LayerMask vehicleLayerToCheck;
[Space]
[Space]
public bool checkVehiclesOnExitingWater;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEvents;
public bool useRemoteEventOnSwimStart;
public List<string> remoteEventNameListOnSwimStart = new List<string> ();
public bool useRemoteEventOnSwimEnd;
public List<string> remoteEventNameListOnSwimEnd = new List<string> ();
[Space]
[Header ("Debug")]
[Space]
public List<GameObject> vehicleDetectedList = new List<GameObject> ();
public bool showGizmo;
public Color gizmoColor = Color.red;
public float gizmoRadius = 0.1f;
[Space]
[Header ("Components")]
[Space]
public Transform swimZoneTransform;
public waterSurfaceSystem mainWaterSurfaceSystem;
public Collider mainTrigger;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!swimZoneActive) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
if (isEnter) {
if (checkVehiclesOnEnteringWater) {
GameObject objectToCheck = col.gameObject;
if ((1 << objectToCheck.layer & vehicleLayerToCheck.value) == 1 << objectToCheck.layer) {
GameObject vehicleGameObject = applyDamage.getVehicle (objectToCheck);
if (vehicleGameObject != null) {
regularVehicleOnWater currentRegularVehicleOnWater = vehicleGameObject.GetComponent<regularVehicleOnWater> ();
if (currentRegularVehicleOnWater != null) {
Collider mainVehicleCollider = currentRegularVehicleOnWater.getMainCollider ();
if (mainVehicleCollider != col) {
return;
}
}
if (vehicleDetectedList.Contains (vehicleGameObject)) {
return;
} else {
vehicleDetectedList.Add (vehicleGameObject);
}
}
if (disableVehiclesInteractionOnEnterWater) {
applyDamage.setVehicleInteractionTriggerState (objectToCheck, false);
}
if (ejectPassengersOnVehicleOnEnterWater) {
applyDamage.ejectAllPassengersFromVehicle (objectToCheck);
}
if (explodeVehiclesAfterXTime) {
applyDamage.activateSelfDestructionOnVehicleExternally (objectToCheck, timeToExplodeVehiclesAfterXTime);
}
if (setVehicleGravityForce) {
applyDamage.setNewVehicleGravityForce (objectToCheck, newVehicleGravityForce);
}
if (reduceVehicleSpeedOnEnterWater) {
applyDamage.setReducedVehicleSpeed (objectToCheck, reducedVehicleSpeedMultiplier);
}
checkRemoteEvents (true, objectToCheck);
}
}
} else {
if (checkVehiclesOnExitingWater) {
GameObject objectToCheck = col.gameObject;
if ((1 << objectToCheck.layer & vehicleLayerToCheck.value) == 1 << objectToCheck.layer) {
GameObject vehicleGameObject = applyDamage.getVehicle (objectToCheck);
if (vehicleGameObject != null) {
regularVehicleOnWater currentRegularVehicleOnWater = vehicleGameObject.GetComponent<regularVehicleOnWater> ();
if (currentRegularVehicleOnWater != null) {
Collider mainVehicleCollider = currentRegularVehicleOnWater.getMainCollider ();
if (mainVehicleCollider != col) {
return;
}
}
if (!vehicleDetectedList.Contains (vehicleGameObject)) {
return;
} else {
vehicleDetectedList.Remove (vehicleGameObject);
}
}
if (setVehicleGravityForce) {
applyDamage.setOriginalGravityForce (objectToCheck);
}
checkRemoteEvents (false, objectToCheck);
}
}
}
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior swimExternalControllerBehavior = currentPlayerComponentsManager.getSwimExternalControllerBehavior ();
if (swimExternalControllerBehavior != null) {
swimSystem currentSwimSystem = swimExternalControllerBehavior.GetComponent<swimSystem> ();
if (mainTrigger == null) {
mainTrigger = GetComponent<Collider> ();
}
currentSwimSystem.addSwimTrigger (mainTrigger);
currentSwimSystem.setSwimZoneTransform (swimZoneTransform);
currentSwimSystem.setSwimTrigger (mainTrigger);
if (updateSurfaceTransformDynamically) {
currentSwimSystem.setCurrentWaterSurfaceSystem (mainWaterSurfaceSystem);
}
currentSwimSystem.setSwimSystemActivestate (true);
checkRemoteEvents (true, currentPlayer);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior swimExternalControllerBehavior = currentPlayerComponentsManager.getSwimExternalControllerBehavior ();
if (swimExternalControllerBehavior != null) {
swimSystem currentSwimSystem = swimExternalControllerBehavior.GetComponent<swimSystem> ();
if (mainTrigger == null) {
mainTrigger = GetComponent<Collider> ();
}
currentSwimSystem.removeSwimTrigger (mainTrigger);
if (currentSwimSystem.isSwimTriggerListEmpty ()) {
currentSwimSystem.setSwimSystemActivestate (false);
currentSwimSystem.setSwimZoneTransform (null);
currentSwimSystem.setSwimTrigger (null);
currentSwimSystem.setCurrentWaterSurfaceSystem (null);
}
checkRemoteEvents (false, currentPlayer);
}
}
}
}
void checkRemoteEvents (bool state, GameObject objectToCheck)
{
if (!useRemoteEvents) {
return;
}
if (state) {
if (useRemoteEventOnSwimStart) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnSwimStart.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnSwimStart [i]);
}
}
}
} else {
if (useRemoteEventOnSwimEnd) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnSwimEnd.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnSwimEnd [i]);
}
}
}
}
}
//Draw gizmos
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
if (swimZoneTransform != null) {
Gizmos.color = gizmoColor;
Vector3 position = swimZoneTransform.position;
Gizmos.DrawSphere (position, gizmoRadius);
Debug.DrawRay (position, transform.position, Color.white);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: cdd0d41c1e184df4fa7cbe214312faf6
timeCreated: 1627609583
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/Extra Movements/swimTriggerSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 35dae826841d85b4495940c8baa42f23
timeCreated: 1641102092
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/Extra Movements/walkOnBalanceSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,155 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class walkOnBalanceTriggerSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool movementZoneActive = true;
public simpleWaypointSystem mainSimpleWaypointSystem;
public bool checkOnTriggerEnter = true;
public bool checkOnTriggerExit = true;
public bool setPlayerAsChild = true;
public Transform playerParentTransform;
[Space]
[Header ("Jump On Target Position Reached Settings")]
[Space]
public bool setJumpOnEndState;
public bool jumpOnEndState;
[Space]
[Header ("Remote Events Settings")]
[Space]
public bool useRemoteEvents;
public bool useRemoteEventOnStart;
public List<string> remoteEventNameListOnStart = new List<string> ();
public bool useRemoteEventOnEnd;
public List<string> remoteEventNameListOnEnd = new List<string> ();
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!movementZoneActive) {
return;
}
if (isEnter) {
if (!checkOnTriggerEnter) {
return;
}
} else {
if (!checkOnTriggerExit) {
return;
}
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior movementExternalControllerBehavior = currentPlayerComponentsManager.getWalkOnBalanceExternaControllerBehavior ();
if (movementExternalControllerBehavior != null) {
walkOnBalanceSystem currentMovementSystem = movementExternalControllerBehavior.GetComponent<walkOnBalanceSystem> ();
if (playerParentTransform == null) {
playerParentTransform = transform;
}
currentMovementSystem.setSetPlayerAsChildStateState (setPlayerAsChild, playerParentTransform);
currentMovementSystem.setCurrentWaypoint (mainSimpleWaypointSystem);
currentMovementSystem.setMovementSystemActivestate (true);
if (setJumpOnEndState) {
currentMovementSystem.setJumpOnEndState (jumpOnEndState);
}
checkRemoteEvents (true, currentPlayer);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior movementExternalControllerBehavior = currentPlayerComponentsManager.getWalkOnBalanceExternaControllerBehavior ();
if (movementExternalControllerBehavior != null) {
walkOnBalanceSystem currentMovementSystem = movementExternalControllerBehavior.GetComponent<walkOnBalanceSystem> ();
currentMovementSystem.setSetPlayerAsChildStateState (false, null);
currentMovementSystem.setMovementSystemActivestate (false);
currentMovementSystem.setCurrentWaypoint (null);
currentMovementSystem.setJumpOnEndState (true);
checkRemoteEvents (false, currentPlayer);
}
}
}
}
void checkRemoteEvents (bool state, GameObject objectToCheck)
{
if (!useRemoteEvents) {
return;
}
if (state) {
if (useRemoteEventOnStart) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnStart.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnStart [i]);
}
}
}
} else {
if (useRemoteEventOnEnd) {
remoteEventSystem currentRemoteEventSystem = objectToCheck.GetComponent<remoteEventSystem> ();
if (currentRemoteEventSystem != null) {
for (int i = 0; i < remoteEventNameListOnEnd.Count; i++) {
currentRemoteEventSystem.callRemoteEvent (remoteEventNameListOnEnd [i]);
}
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d6f5de43177c80b4987823eecb2beced
timeCreated: 1641102528
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/Extra Movements/walkOnBalanceTriggerSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 590da6696ac96f7499b00c27b6a29f42
timeCreated: 1626531706
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/Extra Movements/wallRunningSystem.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 65b06d1a88346ae4f9e6b72f3c9607be
timeCreated: 1633972856
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/Extra Movements/wallSlideJumpSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,78 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class wallSlideJumpZoneSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public string tagToCheck;
public bool slideZoneActive = true;
public float slideDownSpeedMultiplier = 1;
public bool forceSlowDownOnSurfaceActive;
GameObject currentPlayer;
void OnTriggerEnter (Collider col)
{
checkTriggerInfo (col, true);
}
void OnTriggerExit (Collider col)
{
checkTriggerInfo (col, false);
}
public void checkTriggerInfo (Collider col, bool isEnter)
{
if (!slideZoneActive) {
return;
}
if (!col.gameObject.CompareTag (tagToCheck)) {
return;
}
if (isEnter) {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior wallSlideJumpExteralControllerBehavior = currentPlayerComponentsManager.getWallSlideJumpExteralControllerBehavior ();
if (wallSlideJumpExteralControllerBehavior != null) {
wallSlideJumpSystem currentWallSlideJumpSystem = wallSlideJumpExteralControllerBehavior.GetComponent<wallSlideJumpSystem> ();
currentWallSlideJumpSystem.setSlideDownSpeedMultiplier (slideDownSpeedMultiplier);
currentWallSlideJumpSystem.setForceSlowDownOnSurfaceActiveState (forceSlowDownOnSurfaceActive);
currentWallSlideJumpSystem.setCheckIfDetectSlideActiveState (true);
}
}
} else {
currentPlayer = col.gameObject;
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
externalControllerBehavior wallSlideJumpExteralControllerBehavior = currentPlayerComponentsManager.getWallSlideJumpExteralControllerBehavior ();
if (wallSlideJumpExteralControllerBehavior != null) {
wallSlideJumpSystem currentWallSlideJumpSystem = wallSlideJumpExteralControllerBehavior.GetComponent<wallSlideJumpSystem> ();
currentWallSlideJumpSystem.setSlideDownSpeedMultiplier (1);
currentWallSlideJumpSystem.setForceSlowDownOnSurfaceActiveState (false);
currentWallSlideJumpSystem.setCheckIfDetectSlideActiveState (false);
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: c99084ff035b3ac4982f833b7657e716
timeCreated: 1633983350
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/Extra Movements/wallSlideJumpZoneSystem.cs
uploadId: 814740