How Can I Make A Random Color Change 3d

Discussion in 'How Can I...?' started by Sleepypower, Oct 28, 2018.

  1. Sleepypower

    Sleepypower Boxer

    Joined:
    Oct 26, 2018
    Messages:
    12
    Likes Received:
    1
    I want that when a box collides with an object, the box changes its color to a random color or to a list of colors. The only way is by scripts?
     
    Rob Fitzgerald likes this.
  2. particles

    particles Avid Boxer

    Joined:
    Aug 31, 2018
    Messages:
    337
    Likes Received:
    242
  3. Rob Fitzgerald

    Rob Fitzgerald Boxer

    Joined:
    Oct 5, 2018
    Messages:
    4
    Likes Received:
    0
    If you need the script here it is. I have not investigated how to do it with BB nodes.

    Here is the random integer function:

    function getRndInteger(min, max) {
    return Math.floor(Math.random() * (max - min + 1) ) + min;
    }
    Then here is how to change the object:
    this.entity().setColor(getRndInteger(256, 0),getRndInteger(256, 0),getRndInteger(256, 0));
     
  4. Sleepypower

    Sleepypower Boxer

    Joined:
    Oct 26, 2018
    Messages:
    12
    Likes Received:
    1
    Thanks for script rob, but what if a want to get a random selection from a range of colors, let's say i want to randomly choose from these colors in RGB (256,12,25),(52,123,53), etc.
    How can I do that?
     

Share This Page