Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SHOCKING] Procedural Lightning - Fastest, AAA Quality, Dozens of Prefabs and ⚡UNLIMITED POWER!⚡

Discussion in 'Assets and Asset Store' started by jjxtra, Apr 25, 2016.

  1. tomobiki

    tomobiki

    Joined:
    Sep 27, 2020
    Posts:
    65
    Hi, I'm trying to set up the force lightning spell to star from one point and end to another point: I'm using the demo scene DemoSceneSpells to make some tries: I checked the configuration of the prefab of the spell and it's the same of the instance of the same spell in the scene, but my instance doesn't show at all in the scene, even if everything seems ok to me: how can I activate the lightinig? Thanks. I enclose a screenshot where I circled in red the ForceLightningSpell I added that doesn't appear. Unity 2020.3.21f with URP 10.6.0.
    upload_2021-11-4_15-2-36.png
     
    Last edited: Nov 4, 2021
  2. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Were you able to resolve this? Sorry Unity has a forum bug where it stops sending email notifications until I unsubscribe and resubscribe...
     
  3. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    88
    Activating multi threading in a LightningBoltShapeConePrefab doesn't do a thing. All jobs are idle in the profiler.
     
  4. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Sent 2.6.0 update that fixes some issues with multi-threading. On desktop especially newer cpu like i9-12900k the difference is less noticeable.
     
  5. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Also the multi-threading does not use Unity's job system, it uses background threads. Code was written years before Unity job system was usable.
     
  6. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    88
    I think there is a bug in the end width control of the lightning controllers. The end width multiplier only works when the fork end width > 0, and the fork end width modifies both the end widths of the fork and the end width of the main trunks.
     
  7. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    88
    Another apparent bug. When you duplicate a GameObject with a lightning controller, the lightning of the copy gets "messy" when you move the copy. It stays in place while the GameObject is moving. It also sometimes create another visual copy of the lightning.
     
  8. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    My issue is, as soon as I start recording with unity recorder the procedural lightning doesn't appear, no matter I checkbox game time or multi-threading. Unity Recorder = off > hit play in editor and it works. Could that be it, what you are talking about? Because if yes, it sounds like there is no solution for me then O_O
     
  9. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Apologies for not responding the last few months on this forum. Several things have made life very difficult:
    - Nasty cold in March
    - Influenza in April
    - Covid in May
    - Unity bug that has existed for years stops emailing forums post notifications

    I am trying to get my health back and it's slow going, I will try to remember to re-enable the email notifications for the forum more often...
     
  10. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    Hello - is there a way to set the scale of the lightning? I really want to do a "lightning between two fingers" effect, but the lightning is terribly big no matter what parameters what I use. Setting the GameObject's scale doesn't seem to work either. :(
     
  11. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    There is a demo scene for this. It will keep lightning looking nice between twio moving objects.
     
  12. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    Yes, but when you put two objects extremely close (say 0.05 unit), the lightning generated between them is so thick like a rectangle instead of scaled to fit the distance. Do you know if I can tune any parameters to adjust the lightning width?
     
  13. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    The script has a trunk width parameter that could probably get toned down, I will look at adding this to the asset, but for now you could lower it yourself by computing the distance and lowering it.
     
    TigerHix likes this.
  14. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    There is a max scale property on the transform script. Try setting it to 1 or 2.
     
  15. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    Cool thanks! So, is this param not exposed in inspector? Because I swear I tried to adjust every parameter on the inspector yesterday :p I assume it is a non-serialized field in LightningBoltPrefabScript?

    I recall there was a trunk tint color but indeed didn’t see a trunk width param.

    EDIT: Now I see it - it's a private field exposed by the editor script which I removed. Thanks!
     
    Last edited: Mar 8, 2023
    jjxtra likes this.
  16. Rand_D

    Rand_D

    Joined:
    Oct 24, 2017
    Posts:
    44
    Hi, Im trying to make a spell that is somewhat like this video that you posted. The lightning will find a new target and jump to it. How do I make it with this asset ? Also how can I check for collision when the spell hits a target?
     
  17. slippyfrog

    slippyfrog

    Joined:
    Jan 18, 2016
    Posts:
    42
    Great asset! anyway I can add emissive to the material. I'm using URP. Thanks!
     
  18. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Intensity parameter should do it. Then set the color to your desired value.
     
  19. slippyfrog

    slippyfrog

    Joined:
    Jan 18, 2016
    Posts:
    42
    Thanks @jjxtra

    Intensity did indeed work but I had to remove the range on it. It turns out, we have some custom volumetric rendering that is dampening the emissions so things need to be extra emissive.

    The lightening looks great so thanks for the asset and the support! BTW I bought it in 2019 and am just integrating it now. lol
     
  20. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Better late than never!
     
  21. slippyfrog

    slippyfrog

    Joined:
    Jan 18, 2016
    Posts:
    42
    Hello, I'm getting a Deadlock OnDestroy when existing the game (Playmode stop)

    upload_2023-9-13_17-13-35.png


    I'm not doing anything outside of ordinary. I do use a few other assets that use their own threads. (https://arongranberg.com/astar/ and perhaps DoTween).

    Any ideas on what this could be?

    I'm on URP on a Mac with Unity 2022.3.X.

    It seems to happen every few times I press stop to exit play mode.

    Thanks in advance.

    Also I dont use threads in my code whatsoever but use Async loads for scenes, etc.

    Steps:
    Enter play mode
    Exit play mode
    Notice that the game sometimes soft locks.

    Observations:
    pressing the pause in the debugger shows the code is blocking on the
    TerminateAndWaitForEnd method of LightingBoltDataStructures.cs.
     
    Last edited: Sep 13, 2023
  22. AlexanderMerk

    AlexanderMerk

    Joined:
    Nov 9, 2016
    Posts:
    16
    I have the same problem.
    But for me, it happens only if Multi threadeded set to True
     
    slippyfrog likes this.
  23. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    I sent a 2.7.2 update that adds a 5 second timeout to that method and just gives up.
     
    AlexanderMerk likes this.
  24. slippyfrog

    slippyfrog

    Joined:
    Jan 18, 2016
    Posts:
    42
    There is defiantly a threading issue there as I have also disabled multithreading and it works with manifesting the issue. I didn't really profile it but it seems to not take a performance hit for me when running the lightning only on the event thread (disabled threading checkbox).

    So @AlexanderMerk's work-around will do the trick or the 5 second time out from 2.7.2 is fine.. for now. I'm not sure if that will fly with acceptance validation (5 second exit time of an application when the race condition is hit). but for now it is sufficient and we can ship with single threaded (in 1.5 years).


    I' haven't had time to reproduce the issue and it s low priory for us because we can keep it to single-threaded. Some insight from memory when I was looking into it: actionsForBackgroundThread.Count is > 0 when the issue manifests so the while block ends up in an infinite loop.

    Should actionsForBakcgroundThread.Count eventually dwindle down to zero? It seems so in some instances of existing which lead me to believe it likely to be a race condition resulting in the deadlock and actionsForBackgroundThread.Count not getting cleared.

    Anyways thanks for the workaround and hopefully there will be a proper fix in place a some point. I'll send over more data if I get back on the issue. As always, the support is much approached and the asset is pretty awesome.

    **Update**
    Also, if it helps to debug things, I am not sure if is issue presents only in the Editor or if it presents in a Standalone build as well.
     
    Last edited: Oct 25, 2023
    AlexanderMerk likes this.
  25. lgarczyn

    lgarczyn

    Joined:
    Nov 23, 2014
    Posts:
    68
    A few problems with the asset, especially the mesh lightning part

    * crashes if the mesh is not readable
    * infinite loop if pathLength is negative (never stop a loop with a '!= 0', it's so dangerous !)
    * doesn't wait for optimized meshes to be loaded
    * asks for a MeshCollider, doesn't actually use it
     
  26. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    1, 2, 4 fixed in 2.7.3 patch release.

    For 3, what's the recommended approach to waiting for mesh optimization? My assumption is user will optimize their meshes at build time, not runtime.
     
  27. lgarczyn

    lgarczyn

    Joined:
    Nov 23, 2014
    Posts:
    68
    Optimized meshes are always uncompressed at runtime. They are not instantly available, which means that sometimes mesh.vertices.length is 0.

    You simply need to handle that case gracefully, and occasionally check that the 0 has not suddenly become a much larger value.