2026-07-09 이동 애니메이션 추가
This commit is contained in:
Binary file not shown.
@@ -5,11 +5,22 @@ public class NPCController : MonoBehaviour
|
|||||||
private Animator _anim;
|
private Animator _anim;
|
||||||
[SerializeField] private int _defaultAnimNo;
|
[SerializeField] private int _defaultAnimNo;
|
||||||
|
|
||||||
|
private static readonly int _speedHash = Animator.StringToHash("Speed");
|
||||||
|
|
||||||
|
private Vector3 _lastPosition;
|
||||||
|
private float _smoothedSpeed;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_anim = GetComponent<Animator>();
|
_anim = GetComponent<Animator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
_lastPosition = transform.position;
|
||||||
|
_smoothedSpeed = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetAnimState(int animNo)
|
public void SetAnimState(int animNo)
|
||||||
{
|
{
|
||||||
_anim.SetFloat("AnimNo", (float)animNo);
|
_anim.SetFloat("AnimNo", (float)animNo);
|
||||||
@@ -19,4 +30,21 @@ public void SetDefaultAnimState()
|
|||||||
{
|
{
|
||||||
SetAnimState(_defaultAnimNo);
|
SetAnimState(_defaultAnimNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 이동 속도를 재서 Animator의 "Speed" 파라미터로 넘긴다 (블렌드 트리용).
|
||||||
|
// 속도는 위치 변화량으로 직접 잰다 — Rigidbody가 있어도 kinematic + 트랜스폼 직접 이동(타임라인)은
|
||||||
|
// 물리를 안 거쳐서 linearVelocity가 항상 0이기 때문. 타임라인이 위치를 쓴 뒤인 LateUpdate에서 잰다.
|
||||||
|
private void LateUpdate()
|
||||||
|
{
|
||||||
|
if (Time.deltaTime <= 0f) return;
|
||||||
|
|
||||||
|
// 수평 이동 속도 (m/s)
|
||||||
|
Vector3 delta = transform.position - _lastPosition;
|
||||||
|
delta.y = 0f;
|
||||||
|
_lastPosition = transform.position;
|
||||||
|
|
||||||
|
// 프레임 편차로 인한 떨림 방지용 스무딩
|
||||||
|
_smoothedSpeed = Mathf.Lerp(_smoothedSpeed, delta.magnitude / Time.deltaTime, 10f * Time.deltaTime);
|
||||||
|
_anim.SetFloat(_speedHash, _smoothedSpeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,17 +43,25 @@ BlendTree:
|
|||||||
m_DirectBlendParameter: Turn
|
m_DirectBlendParameter: Turn
|
||||||
m_Mirror: 0
|
m_Mirror: 0
|
||||||
- serializedVersion: 2
|
- serializedVersion: 2
|
||||||
m_Motion: {fileID: 7400000, guid: dc4eed9ea5c06794fb28cb39ac93d38d, type: 2}
|
m_Motion: {fileID: 7400050, guid: 3a76ebca0d7213f44b4079b9bb53b121, type: 3}
|
||||||
m_Threshold: 1
|
m_Threshold: 1
|
||||||
m_Position: {x: 0, y: 0}
|
m_Position: {x: 0, y: 0}
|
||||||
m_TimeScale: 1
|
m_TimeScale: 1
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
|
m_DirectBlendParameter: AnimNo
|
||||||
|
m_Mirror: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
m_Motion: {fileID: 7400000, guid: dc4eed9ea5c06794fb28cb39ac93d38d, type: 2}
|
||||||
|
m_Threshold: 2
|
||||||
|
m_Position: {x: 0, y: 0}
|
||||||
|
m_TimeScale: 1
|
||||||
|
m_CycleOffset: 0
|
||||||
m_DirectBlendParameter: Turn
|
m_DirectBlendParameter: Turn
|
||||||
m_Mirror: 0
|
m_Mirror: 0
|
||||||
m_BlendParameter: AnimNo
|
m_BlendParameter: AnimNo
|
||||||
m_BlendParameterY: Turn
|
m_BlendParameterY: Turn
|
||||||
m_MinThreshold: 0
|
m_MinThreshold: 0
|
||||||
m_MaxThreshold: 1
|
m_MaxThreshold: 2
|
||||||
m_UseAutomaticThresholds: 0
|
m_UseAutomaticThresholds: 0
|
||||||
m_NormalizedBlendValues: 0
|
m_NormalizedBlendValues: 0
|
||||||
m_BlendType: 0
|
m_BlendType: 0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: dd9e8bbeedef5514790bf5b4b87a1cd0
|
guid: 32164002d21d2df4f8118eaffdbbf65a
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
BIN
Assets/04_Models/Characters/Yuna_V3/Animations/FeMale_Idle.anim
LFS
Normal file
BIN
Assets/04_Models/Characters/Yuna_V3/Animations/FeMale_Idle.anim
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c7d539d662abb443b4a91849dcc90c1
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/04_Models/Characters/Yuna_V3/Animations/FeMale_Walk.anim
LFS
Normal file
BIN
Assets/04_Models/Characters/Yuna_V3/Animations/FeMale_Walk.anim
LFS
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a02e95c7f33fc5f4ea1e8da0c169b1dc
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!91 &9100000
|
||||||
|
AnimatorController:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: YunaAnimController
|
||||||
|
serializedVersion: 6
|
||||||
|
m_AnimatorParameters:
|
||||||
|
- m_Name: Speed
|
||||||
|
m_Type: 1
|
||||||
|
m_DefaultFloat: 0
|
||||||
|
m_DefaultInt: 0
|
||||||
|
m_DefaultBool: 0
|
||||||
|
m_Controller: {fileID: 9100000}
|
||||||
|
m_AnimatorLayers:
|
||||||
|
- serializedVersion: 5
|
||||||
|
m_Name: Base Layer
|
||||||
|
m_StateMachine: {fileID: 3218860087774146351}
|
||||||
|
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}
|
||||||
|
m_EvaluateTransitionsOnStart: 1
|
||||||
|
--- !u!1102 &2828740930669295434
|
||||||
|
AnimatorState:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Blend Tree
|
||||||
|
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: 5281920114115992255}
|
||||||
|
m_Tag:
|
||||||
|
m_SpeedParameter:
|
||||||
|
m_MirrorParameter:
|
||||||
|
m_CycleOffsetParameter:
|
||||||
|
m_TimeParameter:
|
||||||
|
--- !u!1107 &3218860087774146351
|
||||||
|
AnimatorStateMachine:
|
||||||
|
serializedVersion: 7
|
||||||
|
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: 2828740930669295434}
|
||||||
|
m_Position: {x: -30, y: 100, z: 0}
|
||||||
|
m_ChildStateMachines: []
|
||||||
|
m_AnyStateTransitions: []
|
||||||
|
m_EntryTransitions: []
|
||||||
|
m_StateMachineTransitions: {}
|
||||||
|
m_StateMachineBehaviours: []
|
||||||
|
m_AnyStatePosition: {x: 90, y: 360, z: 0}
|
||||||
|
m_EntryPosition: {x: -20, y: 270, z: 0}
|
||||||
|
m_ExitPosition: {x: 340, y: 360, z: 0}
|
||||||
|
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||||
|
m_DefaultState: {fileID: 2828740930669295434}
|
||||||
|
--- !u!206 &5281920114115992255
|
||||||
|
BlendTree:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Blend Tree
|
||||||
|
m_Childs:
|
||||||
|
- serializedVersion: 2
|
||||||
|
m_Motion: {fileID: 7400000, guid: 5c7d539d662abb443b4a91849dcc90c1, type: 2}
|
||||||
|
m_Threshold: 0
|
||||||
|
m_Position: {x: 0, y: 0}
|
||||||
|
m_TimeScale: 1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_DirectBlendParameter: Speed
|
||||||
|
m_Mirror: 0
|
||||||
|
- serializedVersion: 2
|
||||||
|
m_Motion: {fileID: 7400000, guid: a02e95c7f33fc5f4ea1e8da0c169b1dc, type: 2}
|
||||||
|
m_Threshold: 0.5
|
||||||
|
m_Position: {x: 0, y: 0}
|
||||||
|
m_TimeScale: 1
|
||||||
|
m_CycleOffset: 0
|
||||||
|
m_DirectBlendParameter: Speed
|
||||||
|
m_Mirror: 0
|
||||||
|
m_BlendParameter: Speed
|
||||||
|
m_BlendParameterY: Blend
|
||||||
|
m_MinThreshold: 0
|
||||||
|
m_MaxThreshold: 0.5
|
||||||
|
m_UseAutomaticThresholds: 0
|
||||||
|
m_NormalizedBlendValues: 0
|
||||||
|
m_BlendType: 0
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1124ff6cdc4a797408dde0e4cc791ebf
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 9100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user