본문 바로가기
[ Unity ]/- 유니티 실습

유니티 애니메이션 (애니 레이어 상태, 애니 속도, 재생중 애니 이름, 애니 진행시간)

by MRG 2024. 9. 23.
728x90
반응형

 

▣ animator.speed
설명: animator.speed는 Animator 컴포넌트가 재생하는 모든 애니메이션의 속도를 제어하는 프로퍼티입니다. 기본값은 1.0f이며, 이는 정상 속도를 의미합니다. 0.5f로 설정하면 애니메이션 속도가 절반으로 느려지고, 2.0f로 설정하면 두 배로 빨라집니다. 이 값은 Animator 전체의 재생 속도를 조절하며, 개별 애니메이션 클립에 적용되는 것이 아니라 Animator에 연결된 모든 클립에 적용됩니다.

▣  animator.GetCurrentAnimatorStateInfo(0)
설명: GetCurrentAnimatorStateInfo(int layerIndex)는 Animator에서 특정 레이어에 대한 현재 애니메이션 상태 정보를 반환하는 메서드입니다. layerIndex는 해당 레이어의 인덱스를 나타내며, 기본 레이어는 0입니다. 이 메서드를 통해 현재 재생 중인 애니메이션의 이름, 진행 상황, 길이 등의 정보를 가져올 수 있습니다. 반환 값은 AnimatorStateInfo 구조체로, 이 구조체를 사용해 애니메이션 상태에 대한 다양한 정보를 확인할 수 있습니다.

▣  stateInfo.IsName(string name)
설명: AnimatorStateInfo.IsName(string name)은 현재 재생 중인 애니메이션의 이름이 지정한 name과 같은지 확인하는 메서드입니다. 반환값은 true 또는 false로, 이름이 일치하면 true를 반환하고, 일치하지 않으면 false를 반환합니다. 이 메서드는 애니메이션의 상태가 특정 상태인지 확인하는 데 유용합니다.
사용 예시:

▣ stateInfo.normalizedTime
설명: normalizedTime은 현재 애니메이션의 진행 상황을 0에서 1 사이의 값으로 반환하는 프로퍼티입니다. 0.0은 애니메이션이 막 시작한 상태를 의미하고, 1.0은 애니메이션이 끝났음을 의미합니다. 애니메이션이 반복될 경우 normalizedTime은 1.0을 넘어설 수 있으며, 2.0이면 애니메이션이 두 번 재생되었음을 의미합니다. 이를 통해 애니메이션의 진행 상태를 정확히 확인할 수 있습니다.

 

 

https://docs.unity3d.com/ScriptReference/Animator-speed.html

 

Unity - Scripting API: Animator.speed

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/Animator.GetCurrentAnimatorStateInfo.html

 

Unity - Scripting API: Animator.GetCurrentAnimatorStateInfo

Fetches the data from the current state in the Animator. Use this to get details from the state, including accessing the state’s speed, length, name and other variables. For gathering information from the clips that the states hold, see Animator.GetCurre

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/AnimatorStateInfo.IsName.html

 

Unity - Scripting API: AnimatorStateInfo.IsName

Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close

docs.unity3d.com

https://docs.unity3d.com/ScriptReference/AnimatorStateInfo-normalizedTime.html

 

Unity - Scripting API: AnimatorStateInfo.normalizedTime

The normalized time is a progression ratio. The integer part is the number of times the State has looped. The fractional part is a percentage (0-1) that represents the progress of the current loop. For example, a normalized time of 2.5 means that the State

docs.unity3d.com

 

 

 

 

 

 

728x90
반응형

댓글