Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Zapper: lightning project

Discussion in 'Made With Unity' started by Codster, Feb 14, 2011.

  1. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Dispite wanting to call it; IT'S ALIVE!!! a quick youtube check to 1931 showed me that frankenstein had a lot less lightning then I remember :( . But anyway I have had some spare time on my hands so I have bin trying to make a good looking lighting effect. So far it has bin going pretty good (long way to go still), but I think it's time for some input from the public.

    Looks a lot better in the web player

    single stream thunderbolts

    thunderbolt with multiple streams

    2 emitter examples

    colored "bendy lightning" examples



    All powerful and all in one web player
    http://dl.dropbox.com/u/21083186/thunderIsland/WebPlayer/WebPlayer.html


    Boy dropbox is useful . Anyway if you want any of this shocking examples you can get all of it in this
    unity package V0.7.

    Older versions
    V0.6 no smoothing no glow no lights
    V0.5 No emitter or bendy lightning but has cloud
    V0.4 Does not have the fancy inspector GUI
     
    Last edited: Feb 26, 2011
  2. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Oh and I plan on making this open source/free/do whatever you want with it. So helping me might just help you :D.
     
  3. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Changed the texture from dull FlameA to my much better LightningTex. Looks 4.563295 times as good now (mostly in the web player that is).

    Also changed the top post so you can check it out.
     
  4. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Tuff crowd is seems. Perhaps the thunderbolt addition will help (top post for image and web player). It is only a single stream bolt and no sound atm but I plan to change that. And yes I know my cloud sucks lol.
     
  5. justicar

    justicar

    Joined:
    Dec 21, 2010
    Posts:
    78
    looks cool so far. No immediate ideas what to do with it, but I just woke up.
     
  6. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Thanks justicar. It should just get better and better as it goes on.

    Ok new update I have added multi stream option to the thunderbolt, also the thunderbolt now actually lights up the area around it and a base sound has bin added to the thunderbolt.

    Nothing has really changed with the standard electric zap/shock/plasma channel, not sure what you call something like the 1st image. But anyway now that the thunderbolt is nearing a end, I think I'll go back and see what I can do.
     
  7. RoyS

    RoyS

    Joined:
    Jan 12, 2009
    Posts:
    655
    Nice job on these, King. That thunderbolt with multiple streams is great. I could use these for my game. Thanks for sharing them.
     
  8. Wraith2021

    Wraith2021

    Joined:
    Dec 8, 2010
    Posts:
    81
    Awesome! Thanks King, I have used these for making an electrical barrier in my game, thanks for sharing.
     
  9. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
  10. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,100
    This is really cool. Great job
     
  11. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Thanks for the comments guys.

    @3dDude
    Nice job yourself. I really like your "glow" you have, how did you make it so nice? (hehe had to try lol)

    @everybody else
    If you plan on using this for your game make sure you come back in a day or 2. I should have the next version with all the fancy inspector gui controls by then.
     
    Last edited: Feb 17, 2011
  12. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Well that was easier then I thought it would be (something must be wrong lol). Anyway the inspector GUI's have bin added in. You can now change everything (including color) with ease.
     
  13. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
    Thanks!

    A few suggestions:

    1) Make the spacing for each cut in the mesh even.

    2) Make the first and last position of the lightning bolt be zero so the end does not look flickery.

    3) Make the light on the ground flicker, and make it a cyan color.

    Also, I cant tell you how I made the glow yet... But after the contest is over then you can download it and see how.
     
  14. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    Good job. i like it so much :)
     
  15. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    I'm glad you like it cemC and I have more good news for you (and everyone else)...

    A new update (V0.6). Okay a bit of the background stuff have changed in this one, to hopefully give the code a "cleaner" look. So okay what is on the list;

    1 code has bin updated to #pragma strict to give it that slightest performance boost (I'm talking a whole 0.2fps "GASP" lol)

    2 all examples have bin moved to a single scene

    3 some scripts now can toggle if the run out of sight (using OnBecameVisible/Invisible)

    4 "Lightning" script now has the option to clamp it's start or end or both (thanks for the tip 3dDude)

    5 the thunder noise can be set to dynamically delay itself based on the distance to player and the speed of sound

    6 what started as a attempt to replace "spark" has resulted in a whole new prefab. I call it "bendyLightning" (for lack of a better name). This one is a bit different then the others, do to the fact that it does not have a set point it has to end at. Thus giving it a vary erratic look. However you should keep it's distance under 10 otherwise it looks like some kind of electric explosion (on second thought that could be useful lol). You will find a few of them on posts inside the lab with different colors and being emitted by the emitter examples.

    7 the "Emitter" has bin added what this one does is it creates sparks at random points on a mesh. Giving it a nice tesla coil look, or perhaps can be used for a "being electrocuted" kind of thing. This one has it's own limits as well though. It is a pretty heavy script and is NOT intended for models with large a poly count, or to have it's spread turned well above normal resulting in a sort of electric fur.

    And I have a partridge in a pear tree (jk lol).


    @3dDude
    Thanks for the tips again but I was only able to use the clamp ends bit (in this update anyway) because my scripts do not create light (except for the thunderbolt) thus no flicker for now. As for a cyan color, well most if not all lightning around here is white (maybe with a bit of blue), and in some places it's purple ect ect. But it's not a problem because like I said you can change the color of all examples easily.
     
  16. RoyS

    RoyS

    Joined:
    Jan 12, 2009
    Posts:
    655
    Nice job, King. Of the new ones, I like the one out of the gun especially.
     
  17. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Actually the gun is just 3 normal Lightning's with update distance turned on. So it uses older prefabs but I thought I would show a new way to use it in this update.

    Thanks btw.
     
  18. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Ok another update. It's starting to look like a complete package with this one.
    And on this list of updates for this one we have;

    1 Lightning script has bin completely rewriting giving it about a 15% performance boost without glow or lights turned on. I was able to run 5000 meters this way at 90-100fps.

    2 Lightning script has new features added such as a particle glow effect, ability to create light and controlled speed of jitter.

    3 glow added to thunderbolt and sparks.

    Yup does not sound like much but it really is a big improvement to the last version.

    One thing to note though is that all the quality settings have bin boosted in the web player to show the best look. So if you are experiencing lag in the web player it's probably because everything has bin turned up to a eleven.
     
  19. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,093
    Looks pretty good. The lightning from the clouds outside though lives for too long and sometimes has more random branches than it seems like it should.

    Lightning chooses a path based on least resistance, so a more directed path would be desirable. Sometimes the lightning seems to swing back around towards itself or the sky, this breaks the feel of it for me. But the look the glow and jaggedness of it all looks right.
     
  20. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Actually I'm a step ahead of you. bolt stay time, sparkyness (more or less branches) and spread (deviation from the direct path) and others, are already added in as variables with a easy to use inspectorGUI. Allowing you to just move a few sliders left or right to give you the perfect lightning bolt.

    But the default lightning bolt (thunderbolt in package) is simply what to me felt best. So feel free to change it to your liking.

    Edit:
    Was the main bolt turning up? The branches I allowed to go up slightly if their random rotation turned them horizontal in the beginning. But this should not happen with the main bolt.
     
    Last edited: Feb 26, 2011
  21. OutCyder

    OutCyder

    Joined:
    Mar 19, 2009
    Posts:
    2,176
    Hey how did you manage real time lighting around the main lightening in the room???

    Great work by the way, thanks for sharing :)
     
  22. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,093
    Thats fantastic! No the main bolt did not turn up, just a few of its side branches creating electrical curls which didn't look right to me. Thats great that you have all those variables to tweak! I am sure with a few slider movements I would be able to have something I feel is right. Keep up the fantastic work!
    Thank you for sharing!
     
  23. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Many hours of trial and error :D. Ok what I did is it keeps a array of point lights equal to the length divided by 5 and then I just update their positions to the correct position of one of the line renderers joints. This feature is pretty heavy though so don't go nuts with it. But if you do want it just push the "Create light?" toggle I added in.

    Oh and glad you like it.

    Thanks for the complement. I have noticed this curling you are talking about I'll have to see if I can fix it in a later update.
     
  24. OutCyder

    OutCyder

    Joined:
    Mar 19, 2009
    Posts:
    2,176
    Ye I liked it but I was afraid of this you wrote now eheh :D too intensive, a real waste of lights :D
     
  25. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Completely agree. However it was the only way to give real time lighting in unity basic (maybe even pro but not sure), and you have to admit it does look better. But no worries you just have to set create light to false (default) and then it does not have the performance hit (or lights for that matter).
     
  26. OutCyder

    OutCyder

    Joined:
    Mar 19, 2009
    Posts:
    2,176
    Well, as what a lightening does is light, I'm afraid there's no cheaper way to achieve such an effect :D

    Now, about a feature request: why not add another parameter to grow/shrink the thickness of the stripe randomly along the lightnening?
    Also, you could add two parameters for "start thickness" and "end thickness" :)
     
  27. 3dDude

    3dDude

    Joined:
    Jul 4, 2010
    Posts:
    1,067
    First off all king, if you want, you can check out my submission on musegames.com now!

    Here is what I did. Instead of having for light for every segment, I created two lights and moved them in a random position between point A and point B in the lightning. Then I had them flicker there range. Idk, its a little less costly then a light for every segment.

    Cheers!
     
  28. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
  29. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Well that sounds interesting and doable. Thanks for the request.

    Same to you of corse. I had thought about a way like that. But my results weir... less then desirable lol. But in what I got to work I found a interesting side effect in that it works with updatable distance, which is cool, but I have a lot of optimizing to do.


    Is that daffy duck (or whatever he is called in that one) I see?
    And thanks to all the new submissions to the contest and a duck I am totally pumped to make a super update to this. But I should probably wait in till the end though. Incase any of the others are interested in a collaboration effort to make the ultimate lightning package.
     
  30. Rush-Rage-Games

    Rush-Rage-Games

    Joined:
    Sep 9, 2010
    Posts:
    1,998
    Very cool, thanks!
     
  31. DarthBenedict

    DarthBenedict

    Joined:
    Dec 7, 2010
    Posts:
    26
    Very nice. I've made a few textures that might help with it, will post them when I get home.
     
  32. DarthBenedict

    DarthBenedict

    Joined:
    Dec 7, 2010
    Posts:
    26
  33. ThomQ

    ThomQ

    Joined:
    Nov 23, 2010
    Posts:
    303
    Hi King!
    I've been getting some errors when importing v0.7..



    How do I fix these? Looking forward to trying out your lightning!
     
  34. Codster

    Codster

    Joined:
    Apr 27, 2010
    Posts:
    440
    Wow almost missed this, apparently I don't get a notification when it is updated (wounder how many others threads I have missed).

    @Rush-Rage-Games
    Aim to please

    @DarthBenedict
    Wow thanks! Maybe when I get some time I can update too a version 0.8 and add this in. And again thank you

    @ThomasQ
    It is a casting issue. To fix just replace lines:
    72 with; Destroy((lights[oldLight] as Transform).gameObject);
    136 with; Destroy((lights.Pop() as Transform).gameObject);
    146 with; (lights[l - 1] as Transform).localPosition = curPos[l * 5];

    Thanks for pointing it out I'll upload a fixed package asap.
     
  35. cemolcay

    cemolcay

    Joined:
    Jul 17, 2012
    Posts:
    1
    it's awsome, many thanks ! :)
     
  36. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    231
    wow, this is nice! I've been needing something like this for a long time
     
unityunity