- Home /
Making particles the only render on a camera?
Hi everyone, Im trying to make code that will make everything disappear from the camera, like changing the culling to nothing, but still keep particle effects alone. My code so far changes the culling of the camera, and instantiates particle systems where I want them. However, in the code, the camera cannot see the particles.
#pragma strict
var activated = false;
var everythingCullingMask : LayerMask = -1;
var someStuffCullingMask : LayerMask = (1 << 8);
var MarkedLoc : GameObject;
function Update () {
if(Input.GetKeyDown(KeyCode.T)) {
if(activated) {
activated = false;
Invoke("BackOn", 0.0f);
} else {
activated = true;
}
}
if(activated) {
Camera.main.cullingMask = someStuffCullingMask;
var close : GameObject[];
close = GameObject.FindGameObjectsWithTag("Mob");
for(var mob : GameObject in close) {
var distance = Vector3.Distance(mob.transform.position, transform.position);
if (distance < 100) {
Instantiate(MarkedLoc, mob.transform.position, mob.transform.rotation);
}
}
var delete : GameObject[];
delete = GameObject.FindGameObjectsWithTag("Marker");
for(var del : GameObject in delete) {
Destroy(del, 1);
}
}
if(Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D)) {
activated = false;
Invoke("BackOn", 0.0f);
}
}
function BackOn() {
Camera.main.cullingMask = everythingCullingMask;
}
Thanks
Answer by MiKo51 · Jun 06, 2013 at 02:27 AM
Don't you want to keep culling the layer that the particle system is on?
Yes but I don't know how to do that. This is the first time I have tried something like this. Thanks for the quick response.
Actually I got how to separate the particles into its own layer (go here), but now I'm looking for how to edit my code to go to that layer specifically.
Never $$anonymous$$d, found it, thanks.
Your answer
Follow this Question
Related Questions
Shadows from culled objects 0 Answers
camera.layerCullDistances not working on gameobject with combinechildren 1 Answer
Camera is culling terrain detail objects regardless of settings 6 Answers
How to make camera position relative to a specific target. 1 Answer
Dynamically instantiated game objects not showing in main camera (with background camera) 3 Answers