Changing the colour of object real time?

I have an object that has to change the redness of itself from green to red on the basis of a variable like health! You might have seen in games where our health becomes more reddish from greenish when out health decreases! How do I do that?? I tried once but it didnt change the colour!! I did like this:

I know that there is force instead of health and instead of being red when less i have to make it red when it is high!!
Please How do I do this??

The color values are red;green;blue.
If you want to go from green to red, start with green = 255, red = 0 and adjust values until green = 0 and red =255.
You don’t need to change blue.

Create a text object on the scene to display your color calculations. That way, you can check if your code works as expected (0->255;255->0;0->0).
You need to figure out the calculation depending on your variable.

1 Like

And can you explain this?? I already knew the things you just said!!

Screenshot_6 Screenshot_7 Screenshot_8
There is no change in colour!!
Your reply was not helpful! Maybe help after looking this! Oh It is not properly closed !! So but this works neither why???Screenshot_5

Your syntax is a mess. There is a blue button next to the color picker, you need to use it.

pay attention to syntaxe

VariableString(Red) + ";" + VariableString(Green) + ";0"

1 Like

That is an interesting way saying “I don’t know what is wrong and I don’t understand you, could you please explain it why is this not working?” :expressionless:

Dude, if you don’t know something do not pretend you do because we know you don’t, otherwise you would not ask bull :poop:
Leave the horses and your high minded attitude at home and start at the ground. :kissing_heart:


You should learn more about syntax and the difference between a numerical value, and a text value.
It is because of your lack of knowledge in this area that what you do does not work.

1 Like

Is this not correct?
But it shows blackScreenshot_5

Do you mean like my spaces between … and ; is wrong or I have to add that + sign??
I didnt understand you ! can you explain a little more!

Plz Help First and then comment on my attitude!!

Help wanted

Yeah sure.
Variable(green) return a number value but you are trying to use it as a string, you wan to convert the value to string first using the ToString() expression that you can find in the expression editor that Gruk mentioned and then apply in the value field of the color as Bouh told you.
Everything is explained on the wiki and you can find all the expressions in the expression editor but as I can see from the screenshot, you can’t even use the search on the wiki :joy:
Are you asking how to search or what?

Yet you behave like some sort of general expecting results on command. That’s not the way to ask for help. If you need further help, try to change your attitude maybe.


You still don’t pay attention to what you’re being told.
The articles on the wiki have been given to understand the type of value you need.

At the sight of your code you have not read the links I provided you, otherwise you will have understood your error.

The color value field is a text field. (Button blue on screen from Gruk)
The other types on buttons :

Yes, you need double quotes BUT.
If Red = 0 (Numerical)
When you call a variable this way VariablesString(Red) will return “0” (String)
Because VariablesString() Returns the value as String.
Variable() Returns the value as Numerical.

; is a color separator, it must be type String.
+ is for concatenated values, add this betweens String or Numerical values

I lock this topic during 1 day, you need try to understand thes responses, read the wiki page and test the differents type of values.

When you need help please be more friendly in next responses…

1 Like

This topic was automatically opened after 18 hours.