2
\$\begingroup\$

I am having a problem with assigning a colour to the different meshes that I have on one object. The technique that I have used is the first approach on this site. Is it possible to export a simulation (animation) from Blender to Unity?

So what I would like to do is the following. I have about 107 meshes that are different frames from my shape key animation of my blender model. What I would like to have is that the first mesh will be bright green and up to the 40th mesh the colour turns to be white /greyish...

the best would be if I could assign every mesh by hand a colour, however they are all default materials. And if I assign the object a colour, the whole "animation" is going to be in that colour

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

There are different approaches to this problem. It depends a lot on the look you're trying to achieve.

Texture/Color each Mesh separately

If you want full control over the the resulting animation, this is the way to go. But this is also really cumbersome if you have to set up several animations.

How to do it? Instead of using an array of Mesh objects as your "frames", you could use an array of GameObject. The GameObject can have an individual material, colliders etc. Then instead of swapping the mesh, you would swap (toggle visibility) of the different game-objects.

Animate the color of the material

You could add a start- and end-color variable to your script and interpolate between these colors by altering the renderer.material.color property over time. Depending on the type of material/shader you used, this might work out of the box or will need some tweaks on your material-setup. This is presumably more efficient (and certainly less cumbersome to set up) than swapping GameObjects, but I haven't tested the performance.

Here's the MeshAnimation script from my other answer, but this time with start- and end-color built in as an example: http://pastie.org/4131049

\$\endgroup\$
1
  • \$\begingroup\$ thank you so much!! That is exactly what I was looking for :) \$\endgroup\$
    – Salino
    Jun 22, 2012 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .