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-06.

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)
Top Articles
Pacific Coast Highway
The Ultimate Pacific Coast Highway Road Trip Planner
Mountain Dew Bennington Pontoon
Craglist Oc
Do you need a masters to work in private equity?
Mawal Gameroom Download
Best Private Elementary Schools In Virginia
Best Restaurants In Seaside Heights Nj
Southland Goldendoodles
Edgar And Herschel Trivia Questions
12 Best Craigslist Apps for Android and iOS (2024)
Worcester On Craigslist
Summoner Class Calamity Guide
Wgu Admissions Login
Echo & the Bunnymen - Lips Like Sugar Lyrics
Transfer Credits Uncc
Best Nail Salon Rome Ga
Gem City Surgeons Miami Valley South
Google Flights Missoula
Trac Cbna
WEB.DE Apps zum mailen auf dem SmartPhone, für Ihren Browser und Computer.
St Maries Idaho Craigslist
3476405416
Aris Rachevsky Harvard
Morristown Daily Record Obituary
Panolian Batesville Ms Obituaries 2022
Craigslist Northfield Vt
Sunset Time November 5 2022
13301 South Orange Blossom Trail
208000 Yen To Usd
Grand Teton Pellet Stove Control Board
Vlocity Clm
Fedex Walgreens Pickup Times
Wega Kit Filtros Fiat Cronos Argo 1.8 E-torq + Aceite 5w30 5l
Wasmo Link Telegram
Mg Char Grill
Of An Age Showtimes Near Alamo Drafthouse Sloans Lake
Here’s how you can get a foot detox at home!
Metro 72 Hour Extension 2022
Greater Keene Men's Softball
Kazwire
Miracle Shoes Ff6
Craigslist Mexicali Cars And Trucks - By Owner
Locate phone number
Courtney Roberson Rob Dyrdek
Jamesbonchai
Hk Jockey Club Result
Cleveland Save 25% - Lighthouse Immersive Studios | Buy Tickets
Human Resources / Payroll Information
What your eye doctor knows about your health
Powah: Automating the Energizing Orb - EnigmaticaModpacks/Enigmatica6 GitHub Wiki
32 Easy Recipes That Start with Frozen Berries
Latest Posts
Article information

Author: Lakeisha Bayer VM

Last Updated:

Views: 5803

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Lakeisha Bayer VM

Birthday: 1997-10-17

Address: Suite 835 34136 Adrian Mountains, Floydton, UT 81036

Phone: +3571527672278

Job: Manufacturing Agent

Hobby: Skimboarding, Photography, Roller skating, Knife making, Paintball, Embroidery, Gunsmithing

Introduction: My name is Lakeisha Bayer VM, I am a brainy, kind, enchanting, healthy, lovely, clean, witty person who loves writing and wants to share my knowledge and understanding with you.