3d Object Smoth Color changing,

Hi, im new and i have question. I have 3d object, and it is HP bar for example. I need change color of it material (smooth from green to red) for ex. trough code. Any ideas?

Are you asking how to change the colour so that the colour fades from green to red or how to fill the bar smoothly?

Try going through this post, I got an answer there for applying a rainbow effect.