Unity3DAnimation外文文献.docx
《Unity3DAnimation外文文献.docx》由会员分享,可在线阅读,更多相关《Unity3DAnimation外文文献.docx(15页珍藏版)》请在冰豆网上搜索。
![Unity3DAnimation外文文献.docx](https://file1.bdocx.com/fileroot1/2023-2/2/5c04f16a-5c02-46a5-860f-dbca4298d95a/5c04f16a-5c02-46a5-860f-dbca4298d95a1.gif)
Unity3DAnimation外文文献
Untiy3DAnimation
Unity’sAnimationfeaturesincludeRetargetableanimations,Fullcontrolofanimationweightsatruntime,Eventcallingfromwithintheanimationplayback,SophisticatedStateMachinehierarchiesandtransitions,Blendshapesforfacialanimations,andmore.
Readthissectiontofindouthowtoimportandworkwithimportedanimationandhowtoanimateobjects,colours,andanyotherparameterswithinUnityitself.
AnimationSystemOverview
Unityhasarichandsophisticatedanimationsystem(sometimesreferredtoas‘Mecanim’).Itprovides:
EasyworkflowandsetupofanimationsforallelementsofUnityincludingobjects,characters,andproperties。
Supportforimported animationclips andanimationcreatedwithinUnity
Humanoidanimation retargeting —theabilitytoapplyanimationsfromonecharactermodelontoanother.
Simplifiedworkflowforaligninganimationclips.
Convenientpreviewofanimationclips,transitionsandinteractionsbetweenthem。
Thisallowsanimatorstoworkmoreindependentlyofprogrammers,prototypeandpreviewtheiranimationsbeforegameplaycodeishookedin。
Managementofcomplexinteractionsbetweenanimationswithavisualprogrammingtool。
Animatingdifferentbodypartswithdifferentlogic.
Layeringandmaskingfeatures
Animationworkflow
Unity'sanimationsystemisbasedontheconceptof AnimationClips,whichcontaininformationabouthowcertainobjectsshouldchangetheirposition,rotation,orotherpropertiesovertime.Eachclipcanbethoughtofasasinglelinearrecording.Animationclipsfromexternalsourcesarecreatedbyartistsoranimatorswith3rdpartytoolssuchasMaxorMaya,orcomefrommotioncapturestudiosorothersources.
AnimationClipsarethenorganisedintoastructuredflowchart-likesystemcalledanAnimatorController。
TheAnimatorControlleractsasa“StateMachine”whichkeepstrackofwhichclipshouldcurrentlybeplaying,andwhentheanimationsshouldchangeorblendtogether。
AverysimpleAnimatorControllermightonlycontainoneortwoclips,forexampletocontrolapowerupspinningandbouncing,ortoanimateadooropeningandclosingatthecorrecttime.AmoreadvancedAnimatorControllermightcontaindozensofhumanoidanimationsforallthemaincharacter’sactions,andmightblendbetweenmultipleclipsatthesametimetoprovideafluidmotionastheplayermovesaroundthescene。
Unity’sAnimationsystemalsohasnumerousspecialfeaturesforhandlinghumanoidcharacterswhichgiveyoutheabilityto retargethumanoidanimationfromanysource(Eg。
motioncapture,theassetstore,orsomeotherthird—partyanimationlibrary)toyourowncharactermodel,aswellasadjusting muscledefinitions。
ThesespecialfeaturesareenabledbyUnity’s Avatar system,wherehumanoidcharactersaremappedtoacommoninternalformat。
Eachofthesepieces—the AnimationClips,the AnimatorController,andthe Avatar,arebroughttogetheronaGameObjectviatheAnimatorComponent。
ThiscomponenthasareferencetoanAnimatorController,and(ifrequired)theAvatarforthismodel。
TheAnimatorController,inturn,containsthereferencestothe AnimationClips ituses。
Theabovediagramshowsthefollowing:
AnimationclipsareimportedfromanexternalsourceorcreatedwithinUnity.Inthisexample,theyareimportedmotioncapturedhumanoidanimations。
TheanimationclipsareplacedandarrangedinanAnimatorController.ThisshowsaviewofanAnimatorControllerintheAnimatorwindow.TheStates(whichmayrepresentanimationsornestedsub—statemachines)appearasnodesconnectedbylines。
ThisAnimatorControllerexistsasanassetintheProjectwindow.
Theriggedcharactermodel(inthiscase,theastronaut“Astrella”)hasaspecificconfigurationofboneswhicharemappedtoUnity’scommon Avatar format。
ThismappingisstoredasanAvatarassetaspartoftheimportedcharactermodel,andalsoappearsintheProjectwindowasshown。
Whenanimatingthecharactermodel,ithasanAnimatorcomponentattached.IntheInspectorviewshownabove,youcanseethe AnimatorComponent whichhasboththe AnimatorController andthe Avatar assigned。
Theanimatorusesthesetogethertoanimatethemodel。
TheAvatarreferenceisonlynecessarywhenanimatingahumanoidcharacter.Forothertypesofanimation,onlyanAnimatorControllerisrequired。
Unity’sanimationsystem(Knownas“Mecanim”)comeswithalotofconceptsandterminology。
Ifatanypoint,youneedtofindoutwhatsomethingmeans,gotoour AnimationGlossary。
Legacyanimationsystem
WhileMecanimisrecommendedforuseinmostsituations,UnityhasretaineditslegacyanimationsystemwhichexistedbeforeUnity4.YoumayneedtousewhenworkingwitholdercontentcreatedbeforeUnity4.ForinformationontheLegacyanimationsystem,see thissection
UnityintendstophaseouttheLegacyanimationsystemovertimeforallcasesbymergingtheworkflowsintoMecanim.
AnimationClips
AnimationClipsareoneofthecoreelementstoUnity’sanimationsystem。
Unitysupportsimportinganimationfromexternalsources,andofferstheabilitytocreateanimationclipsfromscratchwithintheeditorusingtheAnimationwindow。
AnimationfromExternalSources
Animationclipsimportedfromexternalsourcescouldinclude:
Humanoidanimationscapturedatamotioncapturestudio
Animationscreatedfromscratchbyanartistinanexternal3Dapplication(suchas3DSMaxorMaya)
Animationsetsfrom3rd—partylibraries(eg,fromUnity’sassetstore)
Multipleclipscutandslicedfromasingleimportedtimeline.
AnimationCreatedandEditedWithinUnity
Unity'sAnimationWindowalsoallowsyoutocreateandeditanimationclips。
Theseclipscananimate:
Theposition,rotationandscaleofGameObjects
Componentpropertiessuchasmaterialcolour,theintensityofalight,thevolumeofasound
Propertieswithinyourownscriptsincludingfloat,int,Vectorandbooleanvariables
Thetimingofcallingfunctionswithinyourownscripts
AnimationfromExternalSources
OverviewofImportedAnimation
AnimationfromexternalsourcesisimportedintoUnityinthesamewayasregular3Dfiles.Thesefiles,whetherthey’regenericFBXfilesornativeformatsfrom3DsoftwaresuchasMaya,Cinema4D,3DStudioMax,cancontainanimationdataintheformofalinearrecordingofthemovementsofobjectswithinthefile。
Insomesituationstheobjecttobeanimated(eg,acharacter)andtheanimationstogowithitcanbepresentinthesamefile.Inothercases,theanimationsmayexistinaseparatefiletothemodeltobeanimated。
Itmaybethatanimationsarespecifictoaparticularmodel,andcannotbere—usedonothermodels。
Forexample,agiantoctopusend—bossinyourgamemighthaveauniquearrangementoflimbsandbones,anditsownsetofanimations。
Inothersituations,itmaybethatyouhavealibraryofanimationswhicharetobeusedonvariousdifferentmodelsinyourscene.Forexample,anumberofdifferenthumanoidcharactersmightallusethesamewalkandrunanimations。
Inthesesituations,it’scommontohaveasimpleplaceholdermodelinyouranimationfilesforthepurposesofpreviewingthem。
Alternatively,itispossibletouseanimationfileseveniftheyhavenogeometryatall,justtheanimationdata。
Whenimportingmultipleanimations,theanimationscaneachexistasseparatefileswithinyourprojectfolder,oryoucanextractmultipleanimationclipsfromasingleFBXfileifexportedastakesfromMotionbuilderorwithaplugin/scriptforMaya,Maxorother3Dpackages。
Youmightwanttodothisifyourfilecontainsmultipleseparateanimationsarrangedonasingletimeline.Forexample,alongmotioncapturedtimelinemightcontaintheanimationforafewdifferentjumpmotions,andyoumaywanttocutoutcertainsectionsofthistouseasindividualclipsanddiscardtherest.Unityprovidesanimationcuttingtoolstoachievethiswhenyouimportallanimationsinonetimelinebyallowingyoutoselecttheframerangeforeachclip。
ImportingAnimationFiles
BeforeanyanimationcanbeusedinUnity,itmustfirstbeimportedintoyourproject.UnitycanimportnativeMaya(.mbor.ma),3DStudioMax(.max)andCinema4D(.c4d)files,andalsogenericFBXfileswhichcanbeexportedfrommostanimationpackages(see thispage forfurtherdetailsonexporting)。
Toimportananimation,simplydragthefiletothe Assets folderofyourproject.Whenyouselectthefileinthe ProjectView youcaneditthe ImportSettings intheinspector.
Workingwithhumanoidanimations
TheMecanimAnimationSystemisparticularlywellsuitedforworkingwithanimationsforhumanoidskeletons。
Sincehumanoidskeletonsareusedextensivelyingames,Unityprovidesaspecializedworkflow,andanextendedtoolsetforhumanoidanimations。
Becauseofthesimilarityinbonestructure,itispossibletomapanimationsfromonehumanoidskeletontoanother,allowingretargeting and inversekinematics。
Withrareexceptions,humanoidmodelscanbeexpectedtohavethesamebasicstructure,representingthemajorarticulatepartsofthebody,headandlimbs。
TheMecanimsystemmakesgooduseofthisideatosimplifytheriggingandcontrolofanimations.AfundamentalstepincreatingaanimationistosetupamappingbetweenthesimplifiedhumanoidbonestructureunderstoodbyMecanimandtheactualbonespresentintheskeleton;inMecanimterminology,thismappingiscalledan Avatar.ThepagesinthissectionexplainhowtocreateanAvatarforyourmodel。
CreatingtheAvatar
Afteramodelfile(FBX,COLLADA,etc。
)isimported,youcanspecifywhatkindofrigitisinthe Rig tabofthe ModelImporteroptions.
Humanoidanimations
ForaHumanoidrig,select Humanoid andclick A