Unity - Scripting API: Animation (2024)

class in UnityEngine

/

Inherits from:Behaviour

/

Implemented in:UnityEngine.AnimationModule

Suggest a change

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

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

The animation component is used to play back animations.

You can assign animation clips to the animation component and control playback from your script.The animation system in Unity is weight-based and supports Animation Blending, Additive animations, Animation Mixing, Layers and full control over all aspects of playback.

For an overview of animation scripting in Unity please read this introduction.

AnimationState can be used to change the layer of an animation, modify playback speed, and for direct control over blending and mixing.

Also Animation supports enumerators. Looping through all AnimationStates is performed like this:

using UnityEngine;using System.Collections;

public class ExampleClass : MonoBehaviour{ public Animation anim;

void Start() { anim = GetComponent<Animation>(); foreach (AnimationState state in anim) { state.speed = 0.5F; } }}

Additional resources: An overview of animation scripting in Unity is here.

Properties

animatePhysicsWhen turned on, animations will be executed in the physics loop. This is only useful in conjunction with kinematic rigidbodies.
clipThe default animation.
cullingTypeControls culling of this Animation component.
isPlayingIs an animation currently being played?
localBoundsAABB of this Animation animation component in local space.
playAutomaticallyShould the default animation clip (the Animation.clip property) automatically start playing on startup?
this[string]Returns the animation state named name.
wrapModeHow should time beyond the playback range of the clip be treated?

Public Methods

AddClipAdds a clip to the animation with name newName.
BlendBlends the animation named animation towards targetWeight over the next time seconds.
CrossFadeFades in the animation with the name animation over a period of time defined by fadeLength.
CrossFadeQueuedCross fades an animation after previous animations has finished playing.
GetClipCountGet the number of clips currently assigned to this animation.
IsPlayingIs the animation named name playing?
PlayPlays an animation without blending.
PlayQueuedPlays an animation after previous animations has finished playing.
RemoveClipRemove clip from the animation list.
RewindRewinds the animation named name.
SampleSamples animations at the current state.
StopStops all playing animations that were started with this Animation.

Inherited Members

Properties

enabledEnabled Behaviours are Updated, disabled Behaviours are not.
isActiveAndEnabledReports whether a GameObject and its associated Behaviour is active and enabled.
gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentGets a reference to a component of type T on the same GameObject as the component specified.
GetComponentInChildrenGets a reference to a component of type T on the same GameObject as the component specified, or any child of the GameObject.
GetComponentIndexGets the index of the component on its parent GameObject.
GetComponentInParentGets a reference to a component of type T on the same GameObject as the component specified, or any parent of the GameObject.
GetComponentsGets references to all components of type T on the same GameObject as the component specified.
GetComponentsInChildrenGets references to all components of type T on the same GameObject as the component specified, and any child of the GameObject.
GetComponentsInParentGets references to all components of type T on the same GameObject as the component specified, and any parent of the GameObject.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
TryGetComponentGets the component of the specified type, if it exists.
GetInstanceIDGets the instance ID of the object.
ToStringReturns the name of the object.

Static Methods

DestroyRemoves a GameObject, component or asset.
DestroyImmediateDestroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindFirstObjectByTypeRetrieves the first active loaded object of Type type.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
FindObjectsOfTypeGets a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.
InstantiateAsyncCaptures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.

Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.

Copyright ©2024 Unity Technologies. Publication Date: 2024-08-05.

Tutorials Community Answers Knowledge Base Forums Asset Store Terms of use Legal Privacy Policy Cookies Do Not Sell or Share My Personal Information

Your Privacy Choices (Cookie Settings)

Unity - Scripting API: Animation (2024)

References

Top Articles
raleigh rooms & shares - craigslist
Durham NC Real Estate - Durham NC Homes For Sale | Zillow
Antisis City/Antisis City Gym
Gamevault Agent
Myhr North Memorial
Www.megaredrewards.com
Best Restaurants In Seaside Heights Nj
Orlando Arrest and Public Records | Florida.StateRecords.org
What is the surrender charge on life insurance?
Breakroom Bw
Betonnen afdekplaten (schoorsteenplaten) ter voorkoming van lekkage schoorsteen. - HeBlad
Classroom 6x: A Game Changer In The Educational Landscape
What is Cyber Big Game Hunting? - CrowdStrike
Images of CGC-graded Comic Books Now Available Using the CGC Certification Verification Tool
"Une héroïne" : les funérailles de Rebecca Cheptegei, athlète olympique immolée par son compagnon | TF1 INFO
Spider-Man: Across The Spider-Verse Showtimes Near Marcus Bay Park Cinema
Ms Rabbit 305
V-Pay: Sicherheit, Kosten und Alternativen - BankingGeek
Is Windbound Multiplayer
683 Job Calls
Living Shard Calamity
Jayah And Kimora Phone Number
Apartments / Housing For Rent near Lake Placid, FL - craigslist
Bento - A link in bio, but rich and beautiful.
Suspiciouswetspot
Cb2 South Coast Plaza
The Creator Showtimes Near Baxter Avenue Theatres
Bi State Schedule
Craigslist Dallastx
Lil Durk's Brother DThang Killed in Harvey, Illinois, ME Confirms
Terrier Hockey Blog
Heavenly Delusion Gif
Hometown Pizza Sheridan Menu
Gold Dipping Vat Terraria
Hireright Applicant Center Login
2132815089
Birmingham City Schools Clever Login
Sdn Fertitta 2024
Former Employees
Smite Builds Season 9
Tfn Powerschool
Noh Buddy
Online-Reservierungen - Booqable Vermietungssoftware
Florida Lottery Powerball Double Play
Willkommen an der Uni Würzburg | WueStart
Zeeks Pizza Calories
Hello – Cornerstone Chapel
Rick And Morty Soap2Day
The 5 Types of Intimacy Every Healthy Relationship Needs | All Points North
How To Connect To Rutgers Wifi
The Missile Is Eepy Origin
Gainswave Review Forum
Latest Posts
Article information

Author: Aracelis Kilback

Last Updated:

Views: 5873

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aracelis Kilback

Birthday: 1994-11-22

Address: Apt. 895 30151 Green Plain, Lake Mariela, RI 98141

Phone: +5992291857476

Job: Legal Officer

Hobby: LARPing, role-playing games, Slacklining, Reading, Inline skating, Brazilian jiu-jitsu, Dance

Introduction: My name is Aracelis Kilback, I am a nice, gentle, agreeable, joyous, attractive, combative, gifted person who loves writing and wants to share my knowledge and understanding with you.