Color Change / Interpolation Trick

Hello fellow GameSalad users!
Does anyone else find it tedious and time consuming to set up color changes?
I came up with a simple, reliable way to change or interpolate an actors color, without having to create 3 'change attribute' or 3 'interpolate' behaviors for Red, Green and Blue. I've found this trick to be quite useful and I implement it in nearly every project I work on.
Here's a link to a sample project with this setup: https://drive.google.com/drive/folders/0B-aAU3Qyg31lZnI5a0hTSl9rRWM?usp=sharing

Create a text attribute in your actor and name it 'color'
Make a rule that if self.color = "red"
interpolate self.Color.Red to 1
interpolate self.Color.Green to 0
interpolate self.Color.Blue to 0

Repeat this process for each color that you'd like to be available for your actor, and then whenever a color change is in order, insert the behavior:
change attribute self.color to "red"

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    It's a nice approach, could be useful in quite a few situations !

    On a side note, you can do the same rainbow changing effect as in your demo file with just these three constrains . . .

    Constrain:
    R to sin(self.time*100)+0.5
    G to sin((self.time*100)+120)+0.5
    B to sin((self.time*100)+240)+0.5

  • rainwaterstudiosrainwaterstudios Member Posts: 198

    @Socks said:
    It's a nice approach, could be useful in quite a few situations !

    On a side note, you can do the same rainbow changing effect as in your demo file with just these three constrains . . .

    Constrain:
    R to sin(self.time*100)+0.5
    G to sin((self.time*100)+120)+0.5
    B to sin((self.time*100)+240)+0.5

    Nice, could be useful for constantly changing colors. I mainly use the text attribute method to change an actors color at specific times, when colliding with another actor, or when reaching a certain position; I only used a repeating timer in the project to cycle through the available colors.

Sign In or Register to comment.