I'm working on isometric game in 2D but didn't find any good tutorial in how to handle animation...any help?
-
\$\begingroup\$ As far as I am aware, the machinima animation system isn't ported to DOTS yet. So you will have to program your own animation system. \$\endgroup\$Philipp– Philipp2020-01-30 11:34:05 +00:00Commented Jan 30, 2020 at 11:34
-
\$\begingroup\$ Oh, and doing some further research, it also appears that the DOTS doesn't have an equivalent to SpriteRenderer yet. How did you solve that problem? \$\endgroup\$Philipp– Philipp2020-01-30 11:38:30 +00:00Commented Jan 30, 2020 at 11:38
2 Answers
Update: There is now an animation package for DOTS which might work better than what is described in this answer, but is still considered highly experimental.
As far as I am aware, the machinima animation system with its convenient visual state machines and animation timelines isn't ported to DOTS yet. So you will have to program your own. My approach would be as follows:
Create a new shared component
Animationwhich refrences the meshes used for all the different animation frames of an animated asset.Create instances of that shared component - one for each asset you want to animate.
Assign those shared
Animationcomponent instances to any entities you want to animate.Create a new system
AnimationSystemwhich queries all entities withAnimation,Unity.Rendering.RenderMeshand any components which are relevant for determining what frame to display (MaybeUnity.Transforms.Rotationto determine the direction it faces? MaybeUnity.Physics.MotionVelocityto determine if it's running or standing? Maybe a component of your own which handles the current state of your entity?).Implement the system to use the data from the components to determine which frame to display, retrieve the mesh for that frame from the
Animationcomponent and apply it to theRenderMesh.meshof the entity.
The DOTS Animation package is no longer usable and the next release isn't planed for quite some time. We have to go back to the Hybrid approach.
Here is a tutorial series that covers 1.0 and it's latest episode covers hybrid animation.
-
\$\begingroup\$ This is currently a link-only answer. These are prone to information rot, and so our usual policy is to convert them to comments. To make this post stand on its own as an Answer, it should include at least a brief summary of the information you hope a reader will glean from this video link — that way it's useful even if the video becomes inaccessible. This also helps attract up-votes, since users can quickly scan the text to assess the quality of the advice without committing to watch a whole YouTube series. \$\endgroup\$2022-11-03 17:35:48 +00:00Commented Nov 3, 2022 at 17:35
-
\$\begingroup\$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review \$\endgroup\$liggiorgio– liggiorgio2022-11-03 20:19:09 +00:00Commented Nov 3, 2022 at 20:19