2
\$\begingroup\$

I'm wanting to have an object that does random animation in Unity, within the object. Basically, I want a floor that has lights that go through it. I'm trying to figure out exactly what is the best way to make that happen. I know there is such a thing as "Procedural Textures" in Unity, but I'm struggling to understand exactly how to make these textures. There are two basic ideas which I have:

  1. Attach a script to the object that I want to place the texture on. That class should manage the texture in all senses of the word. This seems clunky, because it won't show up in the scene mode. This texture would then be assigned in the Start() function for said script.
  2. There exists tools that make these procedural textures, such as Substance. Currently I don't have much of a budget for game development, so I'd like to stay away from anything with a cost (This is more of a hobby for me right now).

Is this the correct way to think about things, or am I missing something fundamental? There seems to be procedural materials that I can't quite understand how they work. Am I missing something else? Thanks!

EDIT:

What I'm trying to do is to have moving lights go across a floor, either as a part of the floor, or even as contained within the floor. I'm considering using some kind of particle system for it, but I've heard about these procedural textures and I thought it was worth a shot to see if they do something similar. I'm also considering using a randomly generated star skybox using a similar method. Specifically, I'm picturing moving lights going across the floor in this image.

enter image description here

\$\endgroup\$
6
  • \$\begingroup\$ Can you describe what you want to accomplish with a bit more detail? \$\endgroup\$ Dec 3, 2015 at 15:52
  • \$\begingroup\$ A picture is worth a thousand words. There are a good dozen or so effects I can think of that could be described as "lights going through a floor" and each will have different implementation considerations. Can you add some reference images to get us on the same page? Also, you say a script-based solution won't be visible in the Scene view, but you can make your scripts ExecuteInEditMode too. You can also write custom material shaders without paying for tools like Substance if you're up for getting deep into the code. \$\endgroup\$
    – DMGregory
    Dec 3, 2015 at 16:25
  • \$\begingroup\$ Good to know about ExecuteInEditMode, I didn't realize that existed... I should look into shaders, that might be what I really should do. I've posted an image of my game, which should help some. Thanks! \$\endgroup\$ Dec 3, 2015 at 16:29
  • 1
    \$\begingroup\$ Your image still doesn't explain what you mean by "moving lights across the floor" — you just showed us a floor with no moving lights. That doesn't help us see what's in your imagination. \$\endgroup\$
    – DMGregory
    Dec 3, 2015 at 16:54
  • 1
    \$\begingroup\$ Maybe you just want some spotlights to move around the scene? \$\endgroup\$
    – Philipp
    Dec 3, 2015 at 18:26

1 Answer 1

1
\$\begingroup\$

It turns out that the trick was to simplify. @Phillip provided me with a trick, that the easiest thing to do was to create a series of small moving lights, that only rendered on the floor. This creates the moving lights that I was looking for. This shows what I was looking for.

enter image description here

How I achieved this:

  1. Create a game object that periodically creates small light sources that move just above the floor.
  2. The floor was already on it's own render layer. I specified the light to only affect that layer. I might change my mind on this later, but for now, I like the effect.
  3. Apply a slight velocity to the objects, some random color, and away they go!

The code looks something like this:

    GameObject obj = new GameObject();
    obj.transform.position = startLocation;

    Light light = obj.AddComponent<Light>();
    light.type = LightType.Point;
    light.intensity = Random.Range(probeMinIntensity, probeMaxIntensity);
    light.cullingMask = 0x1;
    light.bounceIntensity = 0f;

    Rigidbody rigid = obj.AddComponent<Rigidbody>();
    rigid.useGravity = false;
    rigid.velocity = new Vector3(0, 0, 1);

Of course, there's still more work to do, but this was more than enough to get me over the hurdle. Thanks!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .