- Home /
smoothly transmogrify an object as it enters a circle
I've asked a few questions about isolated aspects of this problem, but it's gotten to the point where I ought to just explain the whole thing and see if there are any solutions. Thanks in advance!
I have a brilliant circle of light that moves across the screen with a character. Inside this circle, the world is different -- certain objects appear, others disappear, others experience a change in appearance.
It's straightforward to make objects appear, disappear, or change when they are fully within the light's radius. The tricky thing is when they're only partially within the circle. We want effects like these:
Object disappears within circle:
Object appears within circle:
Object changes within circle:
We're making a 2D game, and we've thought of various depth tricks to accomplish some of these effects, but we'd like a robust, relatively simple solution that we won't have to code around later. It's fine if the solution is just visual, although a way to partially disable colliders would be nice too.
Another option we've thought of is rendering a second camera to a circle texture. With this solution, the circle would actually display a duplicated but altered set of game objects somewhere else in our scene. However, this apparently requires Unity Pro (which we don't want to buy yet). Any other ideas would be greatly appreciated!!
Thanks :)
You don't need Unity Pro for the last thing; you can use a depth mask shader and two cameras. See here: http://www.unifycommunity.com/wiki/index.php?title=ShapeWipe Also the second set of game objects don't have to be somewhere else, and it would be better if they weren't; just use layers.
Hmm. That's a pretty cool script and thanks for sharing it (and writing it!). It might work for our project, though we'd have to hack it in the for loop to not actually fade out.
In terms of layers, do you mean:
That way the 3rd effect would just be the two copies of the same object (one with altered appearance), in the same place but on different layers, which would be perfect since we wouldn't need to hack around the colliders. The 1st and 2nd effects would just be special cases of the first, with a little collider hacking to disable collisions in the disappeared area.
Am I understanding your suggestion correctly?
The script is just a demonstration of the effect I was talking about; I didn't mean that it would work as-is for what you want. I expect you'd write a new script using that principle. As for layers, yes; also physics works with layers as well.
Another demo of the depth mask/2 cameras technique: http://www.starscenesoftware.com/vectrositydemo4.html
BTW: Could you answer this as a answer ins$$anonymous$$d a comment? Because otherwise the question appears in the unanswered list.
Answer by Eric5h5 · Mar 26, 2012 at 01:59 PM
You don't need Unity Pro for the last thing; you can use a depth mask shader and two cameras. See here: http://www.unifycommunity.com/wiki/index.php?title=ShapeWipe Also the second set of game objects don't have to be somewhere else, and it would be better if they weren't; just use layers.
thanks! the code you've shared is definitely full of new concepts and might take a little while to understand, but the general concept it implements definitely seems like the best way to go about things. im hopeful that we'll be able to finish our feature now :)
update: it works great, and the code ended up being quite simple. that Depth$$anonymous$$ask shader with the many-optioned subshader was crucial though, and we definitely wouldn't have come up with it without your help. thanks again.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065530im_/https://answers.unity.com/themes/thub/images/avi.jpg)