Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

how to change sprite color

i have an rgb color >>

public Color red = new Color (218,107,96);

when i set it to the sprite after an action or something like this >>

void OnCollisionEnter2D (Collision2D other)

    {

        if (other.gameObject.tag == "red") {

            gameObject.GetComponent<SpriteRenderer> ().color = red;

        }

    }


.... nothing happens and the color does not change ??

Answers

  • ms07ms07 Member
    edited June 2020

    It will be

    other.gameObject.GetComponent<SpriteRenderer> ().color = red;

    Include other before your code and check result

  • but i want to change the objects color that this script attached to ... not the other object !!

Sign In or Register to comment.