Can anybody help me with changing colors of a mesh in animation? When I change the color and set the keyframe, the last modified color of the mesh is applied on all previous keyframes. When I press i to set keyframe, which keyframe should I choose from the rolling list?
3 Answers
You can key frame the actual color by just hitting "i" on the color box
Starts out blue - hit "i"
Move the timeline and box and change the color and hit "i" again.
You can change color by scripting in case you don't want to resort to rendering. You need to open your text editor and change your colors like so:
def f1(hodnota, what, materialA, materialB):
if (hodnota < 0):
bpy.data.scenes['Scene'].objects[what].material_slots[materialA].material.diffuse_color[2] = value*(-1)
bpy.data.scenes['Scene'].objects[what].material_slots[materialA].material.diffuse_color[1] = 0
bpy.data.scenes['Scene'].objects[what].material_slots[materialA].material.diffuse_color[0] = 0
return value*value
bpy.app.driver_namespace['f1'] = f1
When you are happy with your function, click Run Script button in your text editor. To call the function select your driver object, go to Graph editor -> Drivers and into Expr field code something like
f1(var, 'Cylinder.002', 'Material.001', 'Material.002')
You will need to run the script each time you open your file and it is generally pain in the neck, but in case your computer is too weak to run rendered view or if you want to show what you see when developing, it is a way.
I didn't find a way to attach my blend file. Hopefully this will be enough to get you started or you will find a way to let me know how to attach it.
-
1$\begingroup$ Not a very good advice. Why overcomplicate everything when such a simple functionality is needed? The question is clearly about keyframe animation. It's important to know what tools are best for the job. It is definitely not Python scripting in this case. $\endgroup$ Nov 3, 2018 at 13:00
-
$\begingroup$ Welcome to BSE. Upload to blend-exchange post the link to this question where asked. Note can pass
self
as a reference to the object being driven. IMO drivers are a valid answer to "Change colors during animation?" On closer investigation of question, OP is having trouble with basic key-framing, however demonstrating there is another approach cannot hurt. $\endgroup$ Nov 3, 2018 at 13:49 -
$\begingroup$ It is the only way that worked for me and I thought it would be nice if I shared it in case somebody else needed it as well. $\endgroup$ Nov 4, 2018 at 14:25
How to change colors during animation? with Blender Render.
Repeat steps for your next mesh/object. Thank you!
I
with your mouse hovering over the box. See blender.stackexchange.com/questions/1284/… and blender.stackexchange.com/questions/176/… $\endgroup$