Lens Flare size

Hello!Can i somehow change the size of a flare using scripting?Not the brightness!The size of the actual flare.Let’s say i see a star and as i get away the flare shrinks down,but does not lose its brightness.Please help me :face_with_spiral_eyes:
I only need the command to change its size.

I know that it is possible to change the strength of the flare, the color of the flare, the brightness of the flare:

Strength of flare can be changed by using: RenderSettings.flareStrength
Color of the flare can be changed by using: LensFlare.color
Finally, the brightness of the flare can be changed by using: LensFlare.brightness

I think that you would want to use the first one, in your case.

None of these :frowning:
The first one affects all the flares in the scene
The second one changes the color
The last one changes the brightness

So there is no way doing that,i guess? :frowning:

Cant you just access the LensFlare scripting component and change the flare FlareAssets size, or is this another of these components who are not available inside a script?

I don’t know,can i?That would be awesome,and exacly what i need.
I haven’t found any custom flare script or something on google :frowning:

Then just try it.

This code will change the brightness of the lens flare with distance to the camera. Adjust the “strength” parameter to get the desired effect.

private var strength = 5;

function Update () 
 {
 var heading: Vector3 = gameObject.transform.position - Camera.main.transform.position;
 var dist: float = Vector3.Dot(heading, Camera.main.transform.forward);
 gameObject.GetComponent(LensFlare).brightness = strength/dist;
}

Also, check this out.

http://forum.unity3d.com/threads/89069-REALISTIC-LENS-FLARE!!-Finally-make-them-appear-and-disappear-instantaneously?highlight=lens+flare

1 Like