How do I change colors on a sprite

Taiyo PixelsTaiyo Pixels Posts: 27Member

Hi guys I've been trying to change colors using shaders in godot on the tap of a key.

Say I want to make a time stop with the SPACE key or the 8 button for example where the time stop has all of the colors inverted. Then the KinematicBody2D runs around or something like that or player runs around and then the 2 colors that the sprite has turns red and yellow or purple and white.

How would I do that?

Tags :


  • ZeltaZelta Posts: 122Member

    i think u have many ways to do it, coding, tween or even animation player

    try this

    $Sprite.modulate = Color(0,92,92)

  • TwistedTwiglegTwistedTwigleg Posts: 4,292Admin

    For a shader, I think you need to pass a uniform to tell the shader to change the colors. I would expose a few uniforms for the different colors and an integer for the index, so the shader knows that if the integer is a certain value to map the colors to one of the uniforms.

    Do you have a shader for changing the colors? I think I wrote one at one point, so if you do not have a color changing shader let me know and I’ll see if I can find it.

  • ZeltaZelta Posts: 122Member
    edited April 5

    ah sorry i didnt read shader

    try this:

    shader_type canvas_item;
    void fragment() {
       COLOR = vec4(1,0,1,1);

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file