add some extra assets FX and SFX
This commit is contained in:
@@ -48,10 +48,21 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
public bool useTimeBulletDuration;
|
||||
public float timeBulletDuration;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool useEventsOnTimeBullet;
|
||||
public UnityEvent eventOnTimeBulletStart;
|
||||
public UnityEvent eventOnTimeBulletEnd;
|
||||
|
||||
[Space]
|
||||
[Header ("Time Bullet Animation Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setUnscaledTimeOnAnimator;
|
||||
|
||||
public bool setCharacterAnimationSpeed;
|
||||
public float characterAnimationSpeed = 1.6f;
|
||||
|
||||
[Space]
|
||||
[Header ("Physics Settings")]
|
||||
[Space]
|
||||
@@ -79,7 +90,7 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
public string horizontalAnimatorName = "Horizontal Action";
|
||||
public string verticalAnimatorName = "Vertical Action";
|
||||
|
||||
public float delayToResumeAfterGetUp = 1;
|
||||
//public float delayToResumeAfterGetUp = 1.2f;
|
||||
|
||||
[Space]
|
||||
[Header ("Third Person Camera State Settings")]
|
||||
@@ -119,6 +130,10 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
public bool groundDetectedAfterJump;
|
||||
|
||||
public bool isFullBodyAwarenessActive;
|
||||
|
||||
public float bodyWeight;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
@@ -126,11 +141,20 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
public UnityEvent eventOnStart;
|
||||
public UnityEvent eventOnEnd;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnGetUpForward;
|
||||
public UnityEvent eventOnGetUpBackward;
|
||||
public UnityEvent eventOnGetUpRight;
|
||||
public UnityEvent eventOnGetUpLeft;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventOnGetUpForwardFromBack;
|
||||
public UnityEvent eventOnGetUpBackwardFromBack;
|
||||
public UnityEvent eventOnGetUpRightFromBack;
|
||||
public UnityEvent eventOnGetUpLeftFromBack;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
@@ -155,6 +179,8 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
public Transform playerTransform;
|
||||
|
||||
|
||||
|
||||
Vector3 lookDirection;
|
||||
|
||||
Vector2 mouseAxisValues;
|
||||
@@ -177,7 +203,7 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
string previousCameraState;
|
||||
|
||||
float bodyWeight;
|
||||
string defaultThirdPersonStateName = "";
|
||||
|
||||
Vector3 lastJumpDirection;
|
||||
|
||||
@@ -199,33 +225,32 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
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 ();
|
||||
//if (Time.unscaledTime > delayToResumeAfterGetUp + lastTimeGetup) {
|
||||
// disableMovement ();
|
||||
//}
|
||||
|
||||
if (Time.unscaledTime > 0.3f + lastTimeGetup) {
|
||||
if (!mainPlayerController.isActionActive () && Time.time > mainPlayerController.getLastTimeActionActive () + 0.04f) {
|
||||
disableMovement ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Vector3 aimDirection = mainCameraTransform.forward;
|
||||
if (!isFullBodyAwarenessActive) {
|
||||
Vector3 aimDirection = mainCameraTransform.forward;
|
||||
|
||||
aimDirection.y = 0f;
|
||||
aimDirection.y = 0f;
|
||||
|
||||
aimDirection = aimDirection.normalized;
|
||||
aimDirection = aimDirection.normalized;
|
||||
|
||||
aimDirection = playerTransform.InverseTransformDirection (aimDirection);
|
||||
aimDirection = playerTransform.InverseTransformDirection (aimDirection);
|
||||
|
||||
mainAnimator.SetFloat (horizontalAnimatorID, aimDirection.x);
|
||||
mainAnimator.SetFloat (verticalAnimatorID, aimDirection.z);
|
||||
mainAnimator.SetFloat (horizontalAnimatorID, aimDirection.x);
|
||||
mainAnimator.SetFloat (verticalAnimatorID, aimDirection.z);
|
||||
}
|
||||
|
||||
if (mainPlayerController.isPlayerOnGround ()) {
|
||||
if (Time.unscaledTime > minWaitToCheckOnGroundState + lastTimeMovementActive) {
|
||||
@@ -253,7 +278,7 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
if (useEventsOnTimeBullet && timeBulletActive) {
|
||||
if (Time.unscaledTime > lastTimeMovementActive + timeBulletDuration) {
|
||||
// print (Time.unscaledTime + " " + (lastTimeMovementActive + timeBulletDuration));
|
||||
//print (Time.unscaledTime + " " + (lastTimeMovementActive + timeBulletDuration));
|
||||
|
||||
checkTimeBullet (false);
|
||||
}
|
||||
@@ -262,6 +287,68 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
}
|
||||
}
|
||||
|
||||
public override void updateOnAnimatorIKState ()
|
||||
{
|
||||
if (!updateIKEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
//if (isFullBodyAwarenessActive) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (movementActive) {
|
||||
if (!activateGetUp) {
|
||||
lookDirectionTarget = mainCameraTransform.position + mainCameraTransform.forward * lookDirectionForwardOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFullBodyAwarenessActive) {
|
||||
mainAnimator.SetLookAtWeight (bodyWeight, 1, 1.0f, 1.0f, 0.7f);
|
||||
} else {
|
||||
mainAnimator.SetLookAtWeight (bodyWeight, 0.5f, 1.0f, 1.0f, 0.7f);
|
||||
}
|
||||
|
||||
mainAnimator.SetLookAtPosition (lookDirectionTarget);
|
||||
|
||||
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 setMovementActiveState (bool state)
|
||||
{
|
||||
if (!movementEnabled) {
|
||||
@@ -291,14 +378,36 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
checkTimeBullet (true);
|
||||
} else {
|
||||
bool gettingUpFromBellyResult = false;
|
||||
|
||||
float bodyAngle = Vector3.SignedAngle (playerTransform.forward, mainCameraTransform.forward, playerTransform.up);
|
||||
|
||||
if (Mathf.Abs (bodyAngle) < 100) {
|
||||
gettingUpFromBellyResult = true;
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("gettingUpFromBellyResult " + gettingUpFromBellyResult + " " + Mathf.Abs (bodyAngle));
|
||||
}
|
||||
|
||||
bool lookingForward = false;
|
||||
|
||||
Vector3 movementDirection = playerTransform.forward;
|
||||
|
||||
if (!gettingUpFromBellyResult) {
|
||||
movementDirection *= -1;
|
||||
}
|
||||
|
||||
if (playerInput.getPlayerMovementAxis () != Vector2.zero) {
|
||||
movementDirection = mainPlayerController.getMoveInputDirection ();
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("movementDirection " + movementDirection);
|
||||
print ("getPlayerMovementAxis " + playerInput.getPlayerMovementAxis ());
|
||||
print ("getMoveInputDirection " + mainPlayerController.getMoveInputDirection ());
|
||||
}
|
||||
|
||||
float angle = Vector3.SignedAngle (movementDirection, mainCameraTransform.forward, playerTransform.up);
|
||||
|
||||
float ABSAngle = Mathf.Abs (angle);
|
||||
@@ -319,24 +428,62 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
mainAnimator.SetInteger (actionIDAnimatorID, 0);
|
||||
|
||||
if (lookingForward) {
|
||||
if (ABSAngle < 45) {
|
||||
eventOnGetUpForward.Invoke ();
|
||||
} else if (angle < 0) {
|
||||
eventOnGetUpRight.Invoke ();
|
||||
if (gettingUpFromBellyResult) {
|
||||
if (lookingForward) {
|
||||
if (ABSAngle < 45) {
|
||||
eventOnGetUpForward.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on right");
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on forward");
|
||||
}
|
||||
} else if (angle < 0) {
|
||||
eventOnGetUpRight.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on right");
|
||||
}
|
||||
} else {
|
||||
eventOnGetUpLeft.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on left");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eventOnGetUpLeft.Invoke ();
|
||||
eventOnGetUpBackward.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on left");
|
||||
print ("activating event on backward");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eventOnGetUpBackward.Invoke ();
|
||||
if (lookingForward) {
|
||||
if (ABSAngle < 45) {
|
||||
eventOnGetUpForwardFromBack.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on forward");
|
||||
}
|
||||
} else if (angle < 0) {
|
||||
eventOnGetUpRightFromBack.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on right");
|
||||
}
|
||||
} else {
|
||||
eventOnGetUpLeftFromBack.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on left");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eventOnGetUpBackwardFromBack.Invoke ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("activating event on backward");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkTimeBullet (false);
|
||||
@@ -344,6 +491,18 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
lastJumpDirection = Vector3.zero;
|
||||
}
|
||||
|
||||
if (setUnscaledTimeOnAnimator) {
|
||||
mainPlayerController.setAnimatorUnscaledTimeState (state);
|
||||
}
|
||||
|
||||
if (setCharacterAnimationSpeed) {
|
||||
if (state) {
|
||||
mainPlayerController.setReducedVelocity (characterAnimationSpeed);
|
||||
} else {
|
||||
mainPlayerController.setNormalVelocity ();
|
||||
}
|
||||
}
|
||||
|
||||
groundDetectedAfterJump = false;
|
||||
|
||||
//desactivar el salto y demas acciones que no se puedan hacer, quizas algunas cosas de las armas
|
||||
@@ -388,7 +547,7 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
{
|
||||
jumpCoroutineActive = true;
|
||||
|
||||
yield return new WaitForSeconds (rollOnStartDuration);
|
||||
yield return new WaitForSecondsRealtime (rollOnStartDuration);
|
||||
|
||||
jumpCoroutineActive = false;
|
||||
|
||||
@@ -451,6 +610,8 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
{
|
||||
bool isFirstPersonActive = mainPlayerController.isPlayerOnFirstPerson ();
|
||||
|
||||
isFullBodyAwarenessActive = mainPlayerCamera.isFullBodyAwarenessActive ();
|
||||
|
||||
if (state) {
|
||||
if (startActionWithRoll) {
|
||||
mainAnimator.SetInteger (actionIDAnimatorID, actionIDWithRoll);
|
||||
@@ -461,9 +622,24 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
mainAnimator.SetBool (externalControlleBehaviorActiveAnimatorID, state);
|
||||
|
||||
if (setNewCameraStateOnThirdPerson && !isFirstPersonActive) {
|
||||
previousCameraState = mainPlayerCamera.getCurrentStateName ();
|
||||
if (isFullBodyAwarenessActive) {
|
||||
|
||||
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (newCameraStateOnThirdPerson);
|
||||
} else {
|
||||
if (defaultThirdPersonStateName == "") {
|
||||
defaultThirdPersonStateName = mainPlayerCamera.getDefaultThirdPersonStateName ();
|
||||
|
||||
mainPlayerCamera.setDefaultThirdPersonStateName (newCameraStateOnThirdPerson);
|
||||
|
||||
previousCameraState = mainPlayerCamera.getCurrentStateName ();
|
||||
|
||||
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (newCameraStateOnThirdPerson);
|
||||
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActivePausedState (true);
|
||||
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActiveState (true,
|
||||
newCameraStateOnThirdPerson, newCameraStateOnThirdPerson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
carryingWeaponsPreviously = mainPlayerWeaponsManager.isPlayerCarringWeapon ();
|
||||
@@ -485,12 +661,26 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
mainAnimator.SetInteger (actionIDAnimatorID, 0);
|
||||
|
||||
if (setNewCameraStateOnThirdPerson && !isFirstPersonActive) {
|
||||
if (previousCameraState != "") {
|
||||
if (previousCameraState != newCameraStateOnThirdPerson) {
|
||||
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (previousCameraState);
|
||||
if (isFullBodyAwarenessActive) {
|
||||
|
||||
} else {
|
||||
if (defaultThirdPersonStateName != "") {
|
||||
mainPlayerCamera.setDefaultThirdPersonStateName (defaultThirdPersonStateName);
|
||||
|
||||
defaultThirdPersonStateName = "";
|
||||
}
|
||||
|
||||
previousCameraState = "";
|
||||
if (previousCameraState != "") {
|
||||
if (previousCameraState != newCameraStateOnThirdPerson) {
|
||||
mainPlayerCamera.setCameraStateOnlyOnThirdPerson (previousCameraState);
|
||||
}
|
||||
|
||||
previousCameraState = "";
|
||||
}
|
||||
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActivePausedState (false);
|
||||
|
||||
mainPlayerCamera.setUseCustomThirdPersonAimActiveState (false, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +711,9 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
mainPlayerController.setAddExtraRotationPausedState (state);
|
||||
|
||||
//if (!isFullBodyAwarenessActive) {
|
||||
mainHeadTrack.setHeadTrackSmoothPauseState (state);
|
||||
//}
|
||||
|
||||
mainPlayerController.setUseExternalControllerBehaviorPausedState (state);
|
||||
|
||||
@@ -535,6 +727,8 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
|
||||
mainPlayerController.setIgnoreLookInCameraDirectionOnFreeFireActiveState (state);
|
||||
|
||||
mainPlayerController.setIgnoreLookInCameraDirectionValue (state);
|
||||
|
||||
checkEventOnStateChange (state);
|
||||
|
||||
mainPlayerController.setFootStepManagerState (state);
|
||||
@@ -542,6 +736,23 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
mainPlayerController.setIgnoreInputOnAirControlActiveState (state);
|
||||
|
||||
mainPlayerController.setPlayerActionsInputEnabledState (!state);
|
||||
|
||||
mainPlayerController.setInoreInputOnNewGroundAdherenceActive (state);
|
||||
|
||||
if (state) {
|
||||
mainPlayerCamera.enableOrDisableChangeCameraView (false);
|
||||
} else {
|
||||
mainPlayerCamera.setOriginalchangeCameraViewEnabledValue ();
|
||||
}
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("setPlayerState " + state);
|
||||
}
|
||||
|
||||
if (isFullBodyAwarenessActive) {
|
||||
mainAnimator.SetFloat (horizontalAnimatorID, 0);
|
||||
mainAnimator.SetFloat (verticalAnimatorID, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetActionIdOnTimeBulletJump ()
|
||||
@@ -549,54 +760,6 @@ public class bulletTimeFiringSystem : OnAnimatorIKComponent
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user