2

The only way that I found to import the cloth animation from Blender to Unity for mobile is by exporting each frame as a separate mesh and then replacing it at runtime to create the animation. (if anyone knows other solution please tell me).

The problems is that the "meshToChange = otherMesh" way has a big hit on performance on mobile. I'm curious to see if there is a better way to change the mesh at runtime.

Thank you :)

derHugo
  • 83,094
  • 9
  • 75
  • 115
Vlad Ilisan
  • 63
  • 1
  • 10
  • Did you try a SkinnedMesh or something .. it is definitely **not** the only way to import animations into Unity a definitely not a good way to replace the mesh at runtime .. what you rather want is to deform it on runtime – derHugo Jan 30 '20 at 20:47
  • @derHugo Thanks for you comment. It is late right now and I am going to sleep. Tomorrow I will look into SkinnedMesh. How would I approch this? Get the meshes from blender for each keyframe and then somehow add it to a SkinnedMesh component? Or is there a way to export it like this from blender? – Vlad Ilisan Jan 30 '20 at 22:06
  • You try this plugin? http://forum.unity3d.com/threads/89...system-RELEASE?p=691276&viewfull=1#post691276 – joreldraw Jan 31 '20 at 07:51
  • @joreldraw The link is not working for me. – Vlad Ilisan Jan 31 '20 at 08:45
  • @derHugo You don't need to answer. You put me on the right track and made me try again SkinnedMeshes which worked this time and it is 3-4 times more efficent. I will wait a bit before closing and answering this post, mabye I will learn something better, who knows :). Thank you! – Vlad Ilisan Jan 31 '20 at 08:48
  • @VladIlisan glad to help! And cool that you figured it out on your own - that's what this community should basically be about ;) If you can add a well formatted solution to provide it to others with similar issues would be great. In this case you should probably also edit your question a bit and make it more "findable" ;) – derHugo Jan 31 '20 at 08:56
  • @derHugo I totally agree :). I made the change you suggested me. – Vlad Ilisan Jan 31 '20 at 09:36
  • @VladIlisan no that was not what I ment ^^ ... In your question body please describe exactly what the problem was, what you tried and why these were no good options. As it is now the question would be completely offtopic! – derHugo Jan 31 '20 at 09:38
  • @derHugo I did that the first thing :) I will wait a bit mabye the website need to update if not I will change it again. Weird. Thank for pointing that out! – Vlad Ilisan Jan 31 '20 at 09:49

1 Answers1

3

There are a few ways to do this

1.The best way would be this:

  • Get the keyframes for the baked simulation with a .mdd addon for blender.
  • Import the Blender project in Unity.
  • Add the prefab in a scene.
  • Select you object and go to the Skinned Mesh Renderer component and expand the BlendShapes. There you will find all your data.

After that you will need a script to cycle through the BlendShapes. Here is a simple script that will do the job.

For better information check out this video. Thanks to @derHugo for helping me with this one.

I am not going to focus on the next ones but I will put some references here for anyone interested.

2.Using Alembic files.

If I am correct this is the way the Unity team did it for the short film ADAM. Check out this video.

To note that this will not work for mobile.

3.Cycling and changing the mesh every frame.

This technique is very similar to a 2D animation. All you have to do is export a sequence of fbx's for the animation and then cycle through them. script

Be aware that you will get a huge performance hit from this. With a cloth simulation with around 7k tris changing the mesh every few frames I was getting around 30fps with nothing else in the scene on an IPhone 6.

Vlad Ilisan
  • 63
  • 1
  • 10