working on animations
This commit is contained in:
Submodule Assets/RebootKit updated: 369f7099ad...2d06552025
@@ -37,6 +37,7 @@ namespace RebootReality.jelycho.Feedbacks {
|
||||
PaniniProjection m_PaniniProjection;
|
||||
ChromaticAberration m_ChromaticAberration;
|
||||
|
||||
bool m_IsChargeReady;
|
||||
float m_QuickAttackTimer;
|
||||
|
||||
List<CameraShakeFeedback> m_ActiveCameraShakes = new List<CameraShakeFeedback>();
|
||||
@@ -106,6 +107,14 @@ namespace RebootReality.jelycho.Feedbacks {
|
||||
m_QuickAttackTimer = m_QuickAttackIndicatorDuration;
|
||||
}
|
||||
|
||||
public void ShowChargeReadyIndicator() {
|
||||
m_IsChargeReady = true;
|
||||
}
|
||||
|
||||
public void HideChargeReadyIndicator() {
|
||||
m_IsChargeReady = false;
|
||||
}
|
||||
|
||||
//
|
||||
// @MARK: Actor
|
||||
//
|
||||
@@ -127,19 +136,7 @@ namespace RebootReality.jelycho.Feedbacks {
|
||||
}
|
||||
|
||||
m_QuickAttackTimer -= Time.deltaTime;
|
||||
if (m_QuickAttackTimer <= 0.0f) {
|
||||
float chromaticIntensity = m_ChromaticAberration.intensity.value;
|
||||
chromaticIntensity = Mathf.MoveTowards(chromaticIntensity,
|
||||
0.0f,
|
||||
deltaTime * m_QuickAttackIndicatorChromaticDisappearSpeed);
|
||||
m_ChromaticAberration.intensity.value = chromaticIntensity;
|
||||
|
||||
float paniniIntensity = m_PaniniProjection.distance.value;
|
||||
paniniIntensity = Mathf.MoveTowards(paniniIntensity,
|
||||
0.0f,
|
||||
deltaTime * m_QuickAttackIndicatorPaniniDisappearSpeed);
|
||||
m_PaniniProjection.distance.value = paniniIntensity;
|
||||
} else {
|
||||
if (m_QuickAttackTimer > 0.0f || m_IsChargeReady) {
|
||||
float chromaticIntensity = m_ChromaticAberration.intensity.value;
|
||||
chromaticIntensity = Mathf.MoveTowards(chromaticIntensity,
|
||||
m_QuickAttackIndicatorChromaticIntensity,
|
||||
@@ -151,6 +148,18 @@ namespace RebootReality.jelycho.Feedbacks {
|
||||
m_QuickAttackIndicatorPaniniIntensity,
|
||||
deltaTime * m_QuickAttackIndicatorPaniniAppearSpeed);
|
||||
m_PaniniProjection.distance.value = paniniIntensity;
|
||||
} else {
|
||||
float chromaticIntensity = m_ChromaticAberration.intensity.value;
|
||||
chromaticIntensity = Mathf.MoveTowards(chromaticIntensity,
|
||||
0.0f,
|
||||
deltaTime * m_QuickAttackIndicatorChromaticDisappearSpeed);
|
||||
m_ChromaticAberration.intensity.value = chromaticIntensity;
|
||||
|
||||
float paniniIntensity = m_PaniniProjection.distance.value;
|
||||
paniniIntensity = Mathf.MoveTowards(paniniIntensity,
|
||||
0.0f,
|
||||
deltaTime * m_QuickAttackIndicatorPaniniDisappearSpeed);
|
||||
m_PaniniProjection.distance.value = paniniIntensity;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace RebootReality.jelycho.Items {
|
||||
public interface IItemChargeAction {
|
||||
@@ -26,12 +27,21 @@ namespace RebootReality.jelycho.Items {
|
||||
public AnimationClip block;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct ItemActorMountingConfig {
|
||||
public AssetReferenceGameObject actor;
|
||||
[MaxLength(32)] public string slotName;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ItemConfig {
|
||||
public Sprite icon;
|
||||
|
||||
[Header("Mounting")]
|
||||
[MaxLength(32)] public string characterEquippedMountSlotName = "hand_right";
|
||||
|
||||
public ItemActorMountingConfig[] additionalActorsToMount;
|
||||
|
||||
[Header("Character Animations")]
|
||||
public ItemHandsAnimationClipsSet handsAnimationClipsSets;
|
||||
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace RebootReality.jelycho.Main {
|
||||
[Header("Player")]
|
||||
[SerializeField] AssetReferenceGameObject m_PlayerActorPrefab;
|
||||
|
||||
protected override void Awake() {
|
||||
base.Awake();
|
||||
|
||||
// Time.timeScale = 0.2f;
|
||||
}
|
||||
|
||||
protected override void OnPlayerBecameReady(ulong clientID) {
|
||||
s_Logger.Info($"Player {clientID} became ready");
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using RebootReality.jelycho.Items;
|
||||
using Unity.Collections;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootReality.jelycho.Player {
|
||||
@@ -134,6 +135,7 @@ namespace RebootReality.jelycho.Player {
|
||||
Inventory.OnItemDropped += OnItemDropped;
|
||||
|
||||
m_PlayerAnimator.onQuickAttackFinished.AddListener(OnQuickAttackFinishedAnimation);
|
||||
m_PlayerAnimator.onChargeReady.AddListener(OnChargeReadyAnimation);
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
@@ -141,6 +143,7 @@ namespace RebootReality.jelycho.Player {
|
||||
Inventory.OnItemDropped -= OnItemDropped;
|
||||
|
||||
m_PlayerAnimator.onQuickAttackFinished.RemoveListener(OnQuickAttackFinishedAnimation);
|
||||
m_PlayerAnimator.onChargeReady.RemoveListener(OnChargeReadyAnimation);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -272,6 +275,10 @@ namespace RebootReality.jelycho.Player {
|
||||
SetHandsIdleAnimation();
|
||||
}
|
||||
|
||||
if (RR.World.Context is WorldContext context) {
|
||||
context.FeedbacksManager.HideChargeReadyIndicator();
|
||||
}
|
||||
|
||||
m_IsCharging = false;
|
||||
} else if (m_EquippedItem.Config.canQuickAttack) {
|
||||
if (m_QuickAttackState == QuickAttackState.None) {
|
||||
@@ -307,6 +314,18 @@ namespace RebootReality.jelycho.Player {
|
||||
}
|
||||
}
|
||||
|
||||
void OnChargeReadyAnimation() {
|
||||
if (!m_IsCharging) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_IsSetupAsOwner) {
|
||||
if (RR.World.Context is WorldContext context) {
|
||||
context.FeedbacksManager.ShowChargeReadyIndicator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SecondaryAction() {
|
||||
if (!m_IsSetupAsOwner) {
|
||||
s_Logger.Error("Cannot perform secondary action when not set up as owner.");
|
||||
@@ -338,48 +357,16 @@ namespace RebootReality.jelycho.Player {
|
||||
//
|
||||
// @MARK: Hands animations
|
||||
//
|
||||
void PlayHandsAnimation(string animationName) {
|
||||
// int hash = Animator.StringToHash(animationName);
|
||||
//
|
||||
// if (!m_Animator.HasState(m_HandsLayerIndex, hash)) {
|
||||
// s_Logger.Error($"Animator does not have state with name {animationName}");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// PlayHandsAnimation(hash);
|
||||
}
|
||||
|
||||
void PlayHandsAnimation(int animationHash) {
|
||||
// m_Animator.CrossFade(animationHash, 0.0f, m_HandsLayerIndex);
|
||||
//
|
||||
// if (RR.IsServer()) {
|
||||
// PlayerPlayHandsAnimationEvent handsAnimationEvent = new PlayerPlayHandsAnimationEvent {
|
||||
// AnimationHash = animationHash
|
||||
// };
|
||||
// SendActorEvent((byte)PlayerActorEvents.PlayHandsAnimation, ref handsAnimationEvent);
|
||||
// } else {
|
||||
// PlayerActorRequestHandsAnimationCommand handsAnimationCommand =
|
||||
// new PlayerActorRequestHandsAnimationCommand {
|
||||
// AnimationHash = animationHash
|
||||
// };
|
||||
// SendActorCommand((byte) PlayerActorCommands.RequestHandsAnimation, ref handsAnimationCommand);
|
||||
// }
|
||||
}
|
||||
|
||||
void SetHandsIdleAnimation() {
|
||||
m_PlayerAnimator.PlayHandsIdle();
|
||||
}
|
||||
|
||||
void SetChargingAnimation() {
|
||||
if (m_EquippedItem != null) {
|
||||
// PlayHandsAnimation(m_EquippedItem.Config.chargingAnimation);
|
||||
}
|
||||
m_PlayerAnimator.PlayCharging();
|
||||
}
|
||||
|
||||
void SetChargedUseAnimation() {
|
||||
if (m_EquippedItem != null) {
|
||||
// PlayHandsAnimation(m_EquippedItem.Config.chargedUseAnimation);
|
||||
}
|
||||
m_PlayerAnimator.PlayChargedUse();
|
||||
}
|
||||
|
||||
void PlayQuickAttackAnimation(int combo) {
|
||||
@@ -769,6 +756,7 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
if (m_EquippedItem != null) {
|
||||
m_PlayerAnimator.SetHandsAnimationSet(m_EquippedItem.Config.handsAnimationClipsSets);
|
||||
SpawnAdditionalEquippedItemActors();
|
||||
} else {
|
||||
m_PlayerAnimator.SetHandsAnimationSet(null);
|
||||
}
|
||||
@@ -776,6 +764,13 @@ namespace RebootReality.jelycho.Player {
|
||||
SetHandsIdleAnimation();
|
||||
}
|
||||
|
||||
void SpawnAdditionalEquippedItemActors() {
|
||||
foreach (ItemActorMountingConfig localMountInfo in m_EquippedItem.Config.additionalActorsToMount) {
|
||||
Actor actor = RR.SpawnLocalOnlyActor(localMountInfo.actor, Vector3.zero, Quaternion.identity);
|
||||
actor.MountTo(this, localMountInfo.slotName);
|
||||
}
|
||||
}
|
||||
|
||||
public void WarpTo(Vector3 position) {
|
||||
if (!RR.IsServer()) {
|
||||
s_Logger.Error("Only the server can warp players.");
|
||||
@@ -789,14 +784,7 @@ namespace RebootReality.jelycho.Player {
|
||||
// @MARK: Common
|
||||
//
|
||||
void TickCharacterRotation() {
|
||||
// @TODO: restore old delayed character rotation
|
||||
m_Locomotion.YawRotation = m_Camera.Yaw;
|
||||
|
||||
float3 targetCharacterForward = math.normalize(LookDirection.With(y: 0.0f));
|
||||
float3 currentCharacterForward = math.normalize(m_CharacterForwardTransform.forward.With(y: 0.0f));
|
||||
|
||||
float angleRad = math.acos(math.clamp(math.dot(targetCharacterForward, currentCharacterForward) / (math.length(targetCharacterForward) * math.length(currentCharacterForward)), -1f, 1f));
|
||||
float angleDeg = math.degrees(angleRad);
|
||||
float angleDeg = Mathf.DeltaAngle(m_Camera.Yaw, m_Locomotion.YawRotation);
|
||||
|
||||
bool rotateCharacter = false;
|
||||
float rotateCharacterSpeed = m_CharacterRotateSpeed;
|
||||
@@ -820,11 +808,9 @@ namespace RebootReality.jelycho.Player {
|
||||
if (rotateCharacter) {
|
||||
m_CharacterTurnVelocity = rotateCharacterSpeed * Time.deltaTime;
|
||||
|
||||
Vector3 newForward = Vector3.RotateTowards(currentCharacterForward,
|
||||
targetCharacterForward,
|
||||
math.radians(m_CharacterTurnVelocity),
|
||||
0.0f);
|
||||
m_CharacterForwardTransform.forward = newForward;
|
||||
m_Locomotion.YawRotation = Mathf.MoveTowardsAngle(m_Locomotion.YawRotation,
|
||||
m_Camera.Yaw,
|
||||
m_CharacterTurnVelocity);
|
||||
}
|
||||
|
||||
// Aim Target adjustment
|
||||
@@ -925,6 +911,9 @@ namespace RebootReality.jelycho.Player {
|
||||
float forwardNormalized = localVelocity.z / m_Locomotion.runSpeed;
|
||||
float rightNormalized = localVelocity.x / m_Locomotion.runSpeed;
|
||||
|
||||
forwardNormalized = math.clamp(forwardNormalized, -1.0f, 1.0f);
|
||||
rightNormalized = math.clamp(rightNormalized, -1.0f, 1.0f);
|
||||
|
||||
float turnVelocity = m_CharacterTurnVelocity;
|
||||
if (math.abs(forwardNormalized) > 0.01f ||
|
||||
math.abs(rightNormalized) > 0.01f ||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using RebootKit.Engine.Animations;
|
||||
using RebootReality.jelycho.Items;
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor.Search;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Animations;
|
||||
using UnityEngine.Events;
|
||||
@@ -16,11 +19,124 @@ namespace RebootReality.jelycho.Player {
|
||||
public bool IsGrounded;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class BasicCharacterLocomotionReAnimatorNode : IReAnimatorNode {
|
||||
[field: SerializeField] public string Name { get; private set; }
|
||||
|
||||
[SerializeField] AnimationClip m_IdleClip;
|
||||
[SerializeField] AnimationClip m_RunForwardClip;
|
||||
[SerializeField] AnimationClip m_RunBackwardsClip;
|
||||
[SerializeField] AnimationClip m_StrafeRightClip;
|
||||
[SerializeField] AnimationClip m_StrafeLeftClip;
|
||||
[SerializeField] AnimationClip m_TurnRightClip;
|
||||
[SerializeField] AnimationClip m_TurnLeftClip;
|
||||
[SerializeField] float m_TransitionSpeed = 5.0f;
|
||||
[SerializeField, Range(0.0f, 1.0f)] float m_ForceIdleMagnitudeThreshold = 0.2f;
|
||||
|
||||
AnimationMixerPlayable m_Mixer;
|
||||
float2 m_TargetInput;
|
||||
float2 m_CurrentInput;
|
||||
|
||||
float m_Turning;
|
||||
|
||||
public void Tick(float deltaTime) {
|
||||
if (m_TransitionSpeed > 0.0f) {
|
||||
m_CurrentInput = Vector2.MoveTowards(m_CurrentInput,
|
||||
m_TargetInput,
|
||||
m_TransitionSpeed * deltaTime);
|
||||
} else {
|
||||
m_CurrentInput = m_TargetInput;
|
||||
}
|
||||
|
||||
if (math.length(m_CurrentInput) <= m_ForceIdleMagnitudeThreshold) {
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
m_Mixer.SetInputWeight(i, 0.0f);
|
||||
}
|
||||
|
||||
if (m_Turning > 0.1f) {
|
||||
m_Mixer.SetInputWeight(5, 1.0f);
|
||||
} else if (m_Turning < -0.1f) {
|
||||
m_Mixer.SetInputWeight(6, 1.0f);
|
||||
} else {
|
||||
m_Mixer.SetInputWeight(0, 1.0f);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
float inputMagnitude = math.length(m_CurrentInput);
|
||||
float2 inputNormalized = math.normalizesafe(m_CurrentInput);
|
||||
|
||||
inputMagnitude = math.min(1.0f, inputMagnitude);
|
||||
|
||||
float forwardWeight = math.max(0.0f, math.dot(inputNormalized, new float2(0, 1)) * inputMagnitude);
|
||||
float backwardsWeight = math.max(0.0f, math.dot(inputNormalized, new float2(0, -1)) * inputMagnitude);
|
||||
float rightWeight = math.max(0.0f, math.dot(inputNormalized, new float2(1, 0)) * inputMagnitude);
|
||||
float leftWeight = math.max(0.0f, math.dot(inputNormalized, new float2(-1, 0)) * inputMagnitude);
|
||||
|
||||
float totalWeight = forwardWeight + backwardsWeight + rightWeight + leftWeight;
|
||||
|
||||
if (totalWeight > 1.0f) {
|
||||
forwardWeight /= totalWeight;
|
||||
backwardsWeight /= totalWeight;
|
||||
rightWeight /= totalWeight;
|
||||
leftWeight /= totalWeight;
|
||||
totalWeight = 1.0f;
|
||||
}
|
||||
|
||||
float idleWeight = math.max(0.0f, 1.0f - totalWeight);
|
||||
|
||||
m_Mixer.SetInputWeight(0, idleWeight);
|
||||
m_Mixer.SetInputWeight(1, forwardWeight);
|
||||
m_Mixer.SetInputWeight(2, backwardsWeight);
|
||||
m_Mixer.SetInputWeight(3, rightWeight);
|
||||
m_Mixer.SetInputWeight(4, leftWeight);
|
||||
m_Mixer.SetInputWeight(5, 0.0f);
|
||||
m_Mixer.SetInputWeight(6, 0.0f);
|
||||
}
|
||||
|
||||
public IPlayable Build(PlayableGraph graph) {
|
||||
m_Mixer = AnimationMixerPlayable.Create(graph, 7);
|
||||
|
||||
AnimationClipPlayable idlePlayable = AnimationClipPlayable.Create(graph, m_IdleClip);
|
||||
AnimationClipPlayable runForwardPlayable = AnimationClipPlayable.Create(graph, m_RunForwardClip);
|
||||
AnimationClipPlayable runBackwardsPlayable = AnimationClipPlayable.Create(graph, m_RunBackwardsClip);
|
||||
AnimationClipPlayable strafeRightPlayable = AnimationClipPlayable.Create(graph, m_StrafeRightClip);
|
||||
AnimationClipPlayable strafeLeftPlayable = AnimationClipPlayable.Create(graph, m_StrafeLeftClip);
|
||||
AnimationClipPlayable turnRightPlayable = AnimationClipPlayable.Create(graph, m_TurnRightClip);
|
||||
AnimationClipPlayable turnLeftPlayable = AnimationClipPlayable.Create(graph, m_TurnLeftClip);
|
||||
|
||||
m_Mixer.ConnectInput(0, idlePlayable, 0, 1.0f);
|
||||
m_Mixer.ConnectInput(1, runForwardPlayable, 0, 0.0f);
|
||||
m_Mixer.ConnectInput(2, runBackwardsPlayable, 0, 0.0f);
|
||||
m_Mixer.ConnectInput(3, strafeRightPlayable, 0, 0.0f);
|
||||
m_Mixer.ConnectInput(4, strafeLeftPlayable, 0, 0.0f);
|
||||
m_Mixer.ConnectInput(5, turnRightPlayable, 0, 0.0f);
|
||||
m_Mixer.ConnectInput(6, turnLeftPlayable, 0, 0.0f);
|
||||
|
||||
return m_Mixer;
|
||||
}
|
||||
|
||||
public bool TryFindChild(string name, out IReAnimatorNode node) {
|
||||
node = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetInput(float2 input, float turning) {
|
||||
m_TargetInput = input;
|
||||
m_Turning = turning;
|
||||
}
|
||||
}
|
||||
|
||||
public class CharacterHandsReAnimatorNode : IReAnimatorNode {
|
||||
enum State {
|
||||
None,
|
||||
Idle,
|
||||
QuickAttack
|
||||
QuickAttack,
|
||||
Charging,
|
||||
ChargedIdle,
|
||||
Charged,
|
||||
ChargedUse
|
||||
}
|
||||
|
||||
[field: SerializeField] public string Name { get; private set; }
|
||||
@@ -34,19 +150,33 @@ namespace RebootReality.jelycho.Player {
|
||||
State m_State;
|
||||
|
||||
public event Action OnQuickAttackAnimationFinished = delegate { };
|
||||
public event Action OnCharged = delegate { };
|
||||
|
||||
public void Tick(float deltaTime) {
|
||||
switch (m_State) {
|
||||
|
||||
case State.QuickAttack: {
|
||||
if (m_CurrentPlayable.GetTime() >= m_CurrentPlayable.GetAnimationClip().length &&
|
||||
m_CurrentPlayable.GetPlayState() == PlayState.Playing) {
|
||||
if (IsCurrentClipFinished() && m_CurrentPlayable.GetPlayState() == PlayState.Playing) {
|
||||
m_CurrentPlayable.Pause();
|
||||
OnQuickAttackAnimationFinished?.Invoke();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case State.Charging: {
|
||||
if (IsCurrentClipFinished()) {
|
||||
SetChargedIdle();
|
||||
OnCharged?.Invoke();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case State.ChargedUse: {
|
||||
if (IsCurrentClipFinished()) {
|
||||
SetIdle();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,37 +230,81 @@ namespace RebootReality.jelycho.Player {
|
||||
m_CurrentPlayable.Play();
|
||||
m_State = State.Idle;
|
||||
}
|
||||
|
||||
public void SetCharging() {
|
||||
if (m_ClipsSet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_CurrentPlayable = AnimationClipPlayable.Create(m_Graph, m_ClipsSet.charging);
|
||||
m_Mixer.DisconnectInput(0);
|
||||
m_Mixer.ConnectInput(0, m_CurrentPlayable, 0, 1.0f);
|
||||
|
||||
m_CurrentPlayable.Play();
|
||||
m_State = State.Charging;
|
||||
}
|
||||
|
||||
public void SetChargedIdle() {
|
||||
if (m_ClipsSet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_CurrentPlayable = AnimationClipPlayable.Create(m_Graph, m_ClipsSet.chargedIdle);
|
||||
m_Mixer.DisconnectInput(0);
|
||||
m_Mixer.ConnectInput(0, m_CurrentPlayable, 0, 1.0f);
|
||||
|
||||
m_CurrentPlayable.Play();
|
||||
m_State = State.ChargedIdle;
|
||||
}
|
||||
|
||||
public void PlayChargedUse() {
|
||||
if (m_ClipsSet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_CurrentPlayable = AnimationClipPlayable.Create(m_Graph, m_ClipsSet.chargedUse);
|
||||
m_Mixer.DisconnectInput(0);
|
||||
m_Mixer.ConnectInput(0, m_CurrentPlayable, 0, 1.0f);
|
||||
|
||||
m_CurrentPlayable.Play();
|
||||
m_State = State.ChargedUse;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
bool IsCurrentClipFinished() {
|
||||
return m_CurrentPlayable.GetTime() >= m_CurrentPlayable.GetAnimationClip().length;
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerAnimator : MonoBehaviour {
|
||||
[SerializeField] ReAnimator m_ReAnimator;
|
||||
|
||||
MixerNode m_LocomotionRootMixer;
|
||||
BlendTree2DNode m_GroundBlendTree;
|
||||
BasicCharacterLocomotionReAnimatorNode m_GroundBlendTree;
|
||||
CharacterHandsReAnimatorNode m_Hands;
|
||||
|
||||
// @TODO: for some reason `SetLocomotionParams` is called before awake
|
||||
bool m_IsReady = false;
|
||||
|
||||
public UnityEvent onQuickAttackFinished = new UnityEvent();
|
||||
public UnityEvent onChargeReady = new UnityEvent();
|
||||
|
||||
void Awake() {
|
||||
m_LocomotionRootMixer = m_ReAnimator.FindNode<MixerNode>("locomotion_root");
|
||||
m_LocomotionRootMixer.SetInputWeight(0, 1.0f);
|
||||
m_LocomotionRootMixer.SetInputWeight(1, 0.0f);
|
||||
|
||||
m_GroundBlendTree = m_ReAnimator.FindNode<BlendTree2DNode>("locomotion_ground");
|
||||
m_GroundBlendTree.SetDirection(new float2(0, 1));
|
||||
m_GroundBlendTree = m_ReAnimator.FindNode<BasicCharacterLocomotionReAnimatorNode>("locomotion_ground");
|
||||
m_GroundBlendTree.SetInput(new float2(0, 0), 0.0f);
|
||||
|
||||
m_Hands = m_ReAnimator.FindNode<CharacterHandsReAnimatorNode>("hands");
|
||||
m_Hands.OnQuickAttackAnimationFinished += () => { onQuickAttackFinished?.Invoke(); };
|
||||
m_Hands.OnCharged += () => { onChargeReady?.Invoke(); };
|
||||
|
||||
m_IsReady = true;
|
||||
}
|
||||
|
||||
void Update() {
|
||||
|
||||
}
|
||||
void Update() { }
|
||||
|
||||
public void SetLocomotionParams(PlayerLocomotionAnimatorParams locomotionParams) {
|
||||
if (!m_IsReady) {
|
||||
@@ -142,7 +316,7 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
float2 groundBlendDirection = new float2(locomotionParams.VelocityRightNormalized,
|
||||
locomotionParams.VelocityForwardNormalized);
|
||||
m_GroundBlendTree.SetDirection(groundBlendDirection);
|
||||
m_GroundBlendTree.SetInput(groundBlendDirection, locomotionParams.TurnVelocity);
|
||||
}
|
||||
|
||||
public void SetHandsAnimationSet(ItemHandsAnimationClipsSet clipsSet) {
|
||||
@@ -162,5 +336,13 @@ namespace RebootReality.jelycho.Player {
|
||||
public void PlayHandsIdle() {
|
||||
m_Hands.SetIdle();
|
||||
}
|
||||
|
||||
public void PlayCharging() {
|
||||
m_Hands.SetCharging();
|
||||
}
|
||||
|
||||
public void PlayChargedUse() {
|
||||
m_Hands.PlayChargedUse();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,15 @@ MonoBehaviour:
|
||||
m_AttachmentSockets: []
|
||||
<Config>k__BackingField:
|
||||
icon: {fileID: -137324388, guid: 72d716a5a5f582f43b585b9599f6ecf2, type: 3}
|
||||
characterEquippedMountSlotName: dagger
|
||||
characterEquippedMountSlotName: dagger_right
|
||||
additionalActorsToMount:
|
||||
- actor:
|
||||
m_AssetGUID: 50a5e87baaedf5b46ba52646e8e88b74
|
||||
m_SubObjectName:
|
||||
m_SubObjectGUID:
|
||||
m_SubObjectType:
|
||||
m_EditorAssetChanged: 0
|
||||
slotName: dagger_left
|
||||
handsAnimationClipsSets:
|
||||
idle: {fileID: 5159132439250656024, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
charging: {fileID: -8851864934835179381, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
|
||||
72
Assets/jelycho/core/player/Character_Player.controller
Normal file
72
Assets/jelycho/core/player/Character_Player.controller
Normal file
@@ -0,0 +1,72 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1102 &-776089389026906333
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Daggers_Light_Attack_3_tet
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 68589e37be012ac43a11906a2ae93338, type: 2}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Character_Player
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters: []
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
m_StateMachine: {fileID: 2891799681140177310}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
--- !u!1107 &2891799681140177310
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -776089389026906333}
|
||||
m_Position: {x: 200, y: 0, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -776089389026906333}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9079de55fa2742d4b9a583c8acdc36bd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -1,5 +1,36 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &105949052783897139
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7950042186224496601}
|
||||
m_Layer: 7
|
||||
m_Name: hand_left_slot_dagger
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7950042186224496601
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 105949052783897139}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0.050292086, y: 0.048715312, z: -0.6940488, w: -0.71651495}
|
||||
m_LocalPosition: {x: 0.0142, y: 0.0923, z: 0.0251}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 759515611252976184}
|
||||
m_LocalEulerAnglesHint: {x: 171.97, y: 180, z: -91.82501}
|
||||
--- !u!1 &981148959851682200
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -659,10 +690,14 @@ MonoBehaviour:
|
||||
root: {fileID: 6661496247832138833}
|
||||
localPosition: {x: 0, y: 0, z: 0}
|
||||
localRotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
- socketName: dagger
|
||||
- socketName: dagger_right
|
||||
root: {fileID: 3163379227286582809}
|
||||
localPosition: {x: 0, y: 0, z: 0}
|
||||
localRotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
- socketName: dagger_left
|
||||
root: {fileID: 7950042186224496601}
|
||||
localPosition: {x: 0, y: 0, z: 0}
|
||||
localRotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_PlayerAnimator: {fileID: 4018164798333520760}
|
||||
m_Locomotion: {fileID: 3055557605397218987}
|
||||
m_Camera: {fileID: 7282522638044830840}
|
||||
@@ -740,6 +775,9 @@ MonoBehaviour:
|
||||
onQuickAttackFinished:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
onChargeReady:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &3871962590503854066
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -776,7 +814,7 @@ MonoBehaviour:
|
||||
m_TransitionSpeed: 5
|
||||
m_Inputs:
|
||||
- node:
|
||||
rid: 8982226128795598939
|
||||
rid: 8982226198962110573
|
||||
targetWeight: 1
|
||||
- node:
|
||||
rid: 8982226128795598938
|
||||
@@ -786,36 +824,23 @@ MonoBehaviour:
|
||||
data:
|
||||
<Name>k__BackingField: locomotion_air
|
||||
Clip: {fileID: -203655887218126122, guid: 9c384b0c7d362af4c9743bfcba1938ad, type: 3}
|
||||
- rid: 8982226128795598939
|
||||
type: {class: BlendTree2DNode, ns: RebootKit.Engine.Animations, asm: RebootKit.Engine}
|
||||
data:
|
||||
<Name>k__BackingField: locomotion_ground
|
||||
m_Entries:
|
||||
- clip: {fileID: -3100369314251171874, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
direction:
|
||||
x: 0
|
||||
y: 0
|
||||
- clip: {fileID: 5522812681064789136, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
direction:
|
||||
x: 0
|
||||
y: 1
|
||||
- clip: {fileID: -203655887218126122, guid: b3866b602d1016147b919bcff3918f1b, type: 3}
|
||||
direction:
|
||||
x: 0
|
||||
y: -1
|
||||
- clip: {fileID: -203655887218126122, guid: fba537a9366240d4fa665a7a77add245, type: 3}
|
||||
direction:
|
||||
x: 1
|
||||
y: 0
|
||||
- clip: {fileID: -203655887218126122, guid: adb18eaaff5216c47a5ae86f43e54f58, type: 3}
|
||||
direction:
|
||||
x: -1
|
||||
y: 0
|
||||
m_TransitionSpeed: 5
|
||||
- rid: 8982226128795598943
|
||||
type: {class: CharacterHandsReAnimatorNode, ns: RebootReality.jelycho.Player, asm: RebootReality.jelycho}
|
||||
data:
|
||||
<Name>k__BackingField: hands
|
||||
- rid: 8982226198962110573
|
||||
type: {class: BasicCharacterLocomotionReAnimatorNode, ns: RebootReality.jelycho.Player, asm: RebootReality.jelycho}
|
||||
data:
|
||||
<Name>k__BackingField: locomotion_ground
|
||||
m_IdleClip: {fileID: -3100369314251171874, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
m_RunForwardClip: {fileID: 5522812681064789136, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
m_RunBackwardsClip: {fileID: -203655887218126122, guid: b3866b602d1016147b919bcff3918f1b, type: 3}
|
||||
m_StrafeRightClip: {fileID: -203655887218126122, guid: fba537a9366240d4fa665a7a77add245, type: 3}
|
||||
m_StrafeLeftClip: {fileID: -203655887218126122, guid: adb18eaaff5216c47a5ae86f43e54f58, type: 3}
|
||||
m_TurnRightClip: {fileID: -203655887218126122, guid: 0b2b6f967b2d3d448834061fa68b6443, type: 3}
|
||||
m_TurnLeftClip: {fileID: -203655887218126122, guid: 8954af6e64f1f224b842ff9d924e3764, type: 3}
|
||||
m_TransitionSpeed: 6
|
||||
m_ForceIdleMagnitudeThreshold: 0.05
|
||||
--- !u!54 &3351589437949293952
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1739,7 +1764,7 @@ PrefabInstance:
|
||||
- target: {fileID: 5866666021909216657, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
propertyPath: m_Controller
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
objectReference: {fileID: 9100000, guid: 9079de55fa2742d4b9a583c8acdc36bd, type: 2}
|
||||
- target: {fileID: 5866666021909216657, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
propertyPath: m_CullingMode
|
||||
value: 0
|
||||
@@ -1862,6 +1887,9 @@ PrefabInstance:
|
||||
- targetCorrespondingSourceObject: {fileID: -8679921383154817045, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 5180453452427343145}
|
||||
- targetCorrespondingSourceObject: {fileID: 6502182839619065283, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 7950042186224496601}
|
||||
- targetCorrespondingSourceObject: {fileID: -3321919801592875672, guid: e74130c49b009364f90d176af44766be, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 9181414832138245197}
|
||||
|
||||
Reference in New Issue
Block a user