Search Unity

ArcReactor procedural ray generator

Discussion in 'Assets and Asset Store' started by CatsPawGames, Jun 4, 2014.

  1. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Second tutorial is up! Also, I've updated first tutorial with more footage about shape definition.
     
    Rowlan likes this.
  2. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    579
    I'm using the Lens Flare at end of the beam but I have an issue. The Ignore Layers option doesn't work. I checked in the code and is not used at all. Then I tried to fix it but I realized that Unity doesn't expose any method or property to change the layer mask of a lens flare o_O. Is it possible?
     
  3. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello. Yes, I'm aware of this problem. It's possible to change Ignore Layers with usage of C# reflection, I'll include that in next small update that will be released in about 10 days. If you don't want to wait for Asset Store approval (another 1-2 weeks), please send a message to my support email with your invoice number, and I'll send updated files in reply as soon as they're ready.
     
  4. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    579
    Will reflection work also on iOS?
     
  5. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Simply accessing property should work (I think only Emit causes trouble on iOS), although I didn't(and can't since my iOS dev license expired) test it.
     
  6. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    579
    Yes should be fine. I'll test it.
    I'll send you the invoice number tomorrow. Thank you very much for your prompt support.
     
  7. viveleroi

    viveleroi

    Joined:
    Jan 2, 2017
    Posts:
    87
    How well does this support 2d? I assume this has already been asked, but I don't see a way to search individual threads.

    I'd appreciate seeing some examples of how things look in 2d. The 2d laser pack may be better for my needs, especially since it's cheaper and 2d-focused but I want to look into it before making a decision.
     
  8. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello.

    As far as working with colliders(hit detection, reflections etc.), it fully supports 2D Unity components and have specialized Launcher_2D component for that.

    Visualization-wise, ArcReactor uses standard Unity LineRenderer. I made a simple scene and took screenshots of couple of effects:
    upload_2017-1-6_4-29-2.png

    upload_2017-1-6_4-37-39.png

    There's also 2D demo in combined demo download.

    P.S. Semi-related note, there will be a big update to reflection handling in version 1.8b (planned release date 9th January), right now there might be artifacts if you're using hard reflections ("snap segments to shape" toggle) with some combinations of segment length and smoothing segment count.
     
  9. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
  10. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    It would be a very simple change to Launcher scripts, but to use new system you'll need to change your own scripts since new event system uses interfaces (changes are trivial, but I try my best to make updating process seamless). I use custom reflection-based messaging in my other upcoming assets, so I'll take a look at what solution will fit ArcReactor best.
     
  11. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    I've searched through the documentation and this forum, but what are you supposed to do with the Shape Points on your ArcReactor Arc object when you're using the ArcReactor_Launcher script to actually launch the ray?

    If I set it to zero I get this error
    IndexOutOfRangeException: Array index is out of range.
    ArcReactor_Arc.CalculateShape () (at Assets/ArcReactor/Scripts/ArcReactor_Arc.cs:641)
     
  12. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello.

    You shouldn't do anything with ShapePoints if you're using Launcher (nor with ShapeTransforms for that matter, Launcher should handle shape generation all by itself). Are you sure you're using prefab as Arc in your Launcher, and not object from active scene? If not, then can you send me screenshots of your Launcher and Arc inspectors, or some test project with that problem present (my support email is in my publisher profile on Asset Store)?
     
  13. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    660
    Good afternoon. I've had this pack for awhile and am now just getting around to using it. We actually want our arcs end point to be a static object (its a 3d like cursor object the user controls to modify the environment). Looking through the manual I could not find a way to set a static target for the arc system to go to. Is this already possible and I'm missing it or does it need to be added to the functionality of the system? Seems like a main option you would have when setting up the system (Raycast or static target transform). Anywho, thanks in advance for any info anyone has!
     
  14. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello.

    If you're using simple ArcReactor_Arc system without Launcher component involved, just use ShapeTransforms array for shape definition - arcs will be drawn between all transforms in this array, and will dynamically follow transforms during runtime. So, for a simple ray between some starting point and your 3d cursor, place starting point as first element of ShapeTranforms, and your cursor as second. Note that you aren't limited to two shape transforms only - there can be any number of them and arcs will go through all of them.

    If you're using Launcher (component that handles raycasting), just use transform.LookAt on GameOjbect said Launcher is parented to.
     
    Tethys likes this.
  15. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    27
    Hey, I'm attempting to use the PoolManager script and currently it's creating the instances at the root level of the hierarchy, what I'd like to do is have them appear as child objects of the game object the PoolManager script is on, is this possible?
     
  16. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello. I quickly updated pool script, it's attached, place transform you want to parent inactive rays to into "poolParent" slot. More comprehensible update will be included in the next version.
     

    Attached Files:

    Squeyed likes this.
  17. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    27
    You are awesome! Thanks!

    Edit: They are still appearing in the old location sadly.
     
    Last edited: Apr 24, 2017
  18. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Did you fill "poolParent" parameter?

    Also I might misunderstood you. If you want active (not reserve in pool) objects to be parented to other object, you need to change parents in your scripts after you get instance from pool manager or, if you're using Launcher, use "globalSpaceTransform" parameter of Launcher component.
     
  19. Squeyed

    Squeyed

    Joined:
    Aug 26, 2016
    Posts:
    27
    You are totally correct, I had meant the latter, it all works wonderfully now thank you. The new parent parameter works spot on!
     
  20. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    The latest SteamVR player prefab (the thing that replaces your basic camera with a VR camera system) breaks the ArcReactor because their camera changes based on what VR equipment is present. The ArcReactor script relies on a "main camera" which no longer exists. Any ideas on the best way to tackle this?
     
  21. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Currently there is "mainCamera" parameter in ArcReactor main component that can override Camera.main. But, if you're using Launchers, it can be inconvenient to use. I changed a few things:
    1) Changed mainCamera, which was type of Camera, to mainCameraTranform - type of Transform
    2) Added mainCameraTransform to Launchers, so they can transfer this parameter to all spawned arc systems

    So, to use it with new VR system: create transform that will roughly be at(and follow) eyes position, put it into mainCameraTransforms of your Launchers on scene (or mainCameraTransforms of your arc systems, if you're using them directly). That should do the trick.

    Update will be available in 1-2 weeks, and, as always, anyone can send me email with invoice from Asset Store and I'll send update manually.
     
  22. Verstkabond

    Verstkabond

    Joined:
    Feb 3, 2017
    Posts:
    2
    ArcReactor Rays Generator Errors

    We used your RedEnergyRay_trail effect with the ArcReactor_Arc script. The effect is created by the script through Instantiate and the shapeTransforms array is filled. When you start everything works, the effect is displayed, but the console displays the following errors:
    Invalid AABB a
    Invalid AABB aabb
    Invalid AABB rkBox
    Assertion failed on expression: 'IsFinite (outDistanceForSort)'
    Assertion failed on expression: 'IsFinite (outDistanceAlongView)'

    Unity version 5.6.0p3
    Errors are displayed without stacking. Could you suggest how to fix this, because of what these errors are displayed
     
  23. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello, I received your letter, I'll try to replicate it and contact you during this week.
     
  24. f-Schmitz

    f-Schmitz

    Joined:
    Nov 6, 2013
    Posts:
    2
    we have the same problem in Unity 5.5.2
     
  25. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    I'm having an issue where sometimes my arc ray will get stuck in the wrong position. I have the shape transforms set to the correct locations but the ArcLineRenderer line renderer positions are incorrect. They seem to be shifted in the Y direction slightly. It's a rare occurrence which happens with some frequent parenting unparenting, I think. If you have any ideas why this is happening or maybe there's a command I can call occasionally to reset this position it would be greatly appreciated. laser.png laser 2.png
     
  26. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello.

    It is a strange issue, I would appreciate screenshot of full ArcReactor_Arc settings and shape transforms inspectors.

    Some suggestions: since it seems like you're using it for weapons, try using Launcher. If you want to reset position manually, call Initialize() on ArcReactor_Arc component.
     
  27. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
  28. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    I would love to be able to set a bunch of Shape Transforms via scripting. Similar to how you would use LineRenderer.SetPosition. Is there a simple way to do this with the current ArcReactor_Arc script?

    Something like:
    Code (CSharp):
    1. for (int i = 0; i < shapeNumber; i++) {
    2.             arcReactorArc.SetPosition(i, randomVector3s);
    3.         }
    Would be amazing.
     
  29. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    You can access shapeTransforms and shapePoints(for Vectors instead of Transforms) arrays through code, they're public variables of Arc component. So, to set a new transform simply use arcReactorArc.shapeTransforms = yourNewTransform. You can use Array.Resize to change size of arrays (or simply provide new array, depending on how often you do it).

    I'll think about a method for more convenient access to it (e.g. checking if resizing array is necessary etc.).
     
  30. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    I gave it a shot and was able to fill the Shape Points array with
    Code (CSharp):
    1. arcReactor.shapePoints = positionList;
    But sadly it seems that Array.Resize doesn't seem to work. I tried
    Code (CSharp):
    1. Array.Resize(ref arcReactor.shapePoints, positionNumber);
    and it compiles fine it's just not changing. From what I was able to find online it's possible Unity doesn't support it.

    Thanks for getting back to me though! Let me know if this ends up being a feature! :)
     
  31. wyatts

    wyatts

    Joined:
    Apr 15, 2014
    Posts:
    12
    Turns out I don't need to resize the array independently after the fact. I can get what I need by just updating the shapePoints array.

    Cheers
     
  32. jayfelsman

    jayfelsman

    Joined:
    Jul 24, 2013
    Posts:
    9
    Is this asset still being developed or updated? I just noticed the developers websites are down and I was about the implement arc reactor in my project but it hasn't been updated in a while on the asset store.

    Cheers.
     
  33. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    4,881
    I believe the asset is still being supported by the developer. If you look just above, the dev responded to a forum inquiry just a couple of weeks ago, on the 19th, and when I click for the publisher's website, I get the correct Twitter account coming up.

    But we'll see. Hopefully @CatsPawGames will show up and clarify the situation.
     
  34. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello. Asset is being supported normally, and next update is coming this month (it was supposed to come much earlier, but changes to some core functionality caused many bugs). There was problems with hosting with a website that hosts manuals and demos, but they're resolved for now.
     
    Rowlan and hopeful like this.
  35. mr_b

    mr_b

    Joined:
    Nov 23, 2016
    Posts:
    4
    I've been having some trouble with enabling and disabling the flares options

    basically I want the flare to show up when the beam is colliding with another object
    and to not appear when the beam is not colliding with anything.

    what happens with my current code is that when the the weapon is first fire it works fine... and once I "hit" something things work as expected until I am no longer hitting another object. the Flare does not disappear as expected but rather stays at whatever distance from the origin it last spawned at...

    here is a youtube video link of the behavior:



    this is the error message I'm getting in the inspector:

    here is the coroutine I am using while the "fire laser beam" button is being pressed (where "beamWeapon" is the ArcReactor_Arc object):

    Code (CSharp):
    1. private void Update()
    2.     {
    3.         if (player.GetButton("Fire Primary"))
    4.         {
    5.             StopCoroutine(FireLaser());
    6.             StartCoroutine(FireLaser());
    7.         }
    8.     }
    9.  
    10.     private IEnumerator FireLaser()
    11.     {
    12.         beamWeapon.gameObject.SetActive(true);
    13.  
    14.         while (player.GetButton("Fire Primary"))
    15.         {
    16.             myEnergy.Drain(energyDrain);
    17.  
    18.             Ray ray = new Ray(beamStart.transform.position, transform.forward);
    19.             RaycastHit hit;
    20.  
    21.             beamWeapon.shapePoints[0] = beamStart.position;
    22.  
    23.             if (Physics.Raycast(ray, out hit, 6.5f))
    24.             {
    25.                 beamWeapon.shapePoints[1] = hit.point;
    26.                 beamWeapon.arcs[0].flaresOptions.endFlare.enabled = true;
    27.             }
    28.             else
    29.             {
    30.                 beamWeapon.shapePoints[1] = ray.GetPoint(6.5f);
    31.                 beamWeapon.arcs[0].flaresOptions.endFlare.enabled = false;
    32.             }
    33.             yield return null;
    34.         }
    35.         beamWeapon.gameObject.SetActive(false);
    36.     }
    I'm not and advanced coder, I am wondering if I am implementing this effect correctly? of if there is a better way to turn the flare on and off?
     
  36. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Your code looks good except one part - dynamically enabling/disabling flares through flaresOptions at runtime might cause issues since flares objects already been generated, so it's better to manipulate those generated object itself. To do that, you first need to declare endFlares[] array of ArcReactor_Arc public instead of protected. Then just access this array (it consists of LensFlare components) and disable/enable them.

    Meanwhile I'll try to make changes to flaresOptions and make .enabled property instead of variable so it'll switch flares automatically when you change it.
     
  37. mr_b

    mr_b

    Joined:
    Nov 23, 2016
    Posts:
    4
    Thanks for the tip!
     
  38. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Version 1.9 is pending approval by Asset Store team, should be available for download in 3-5 days.

    Next focus is optimizing oscillations (they are responsible for chunk of CPU load in long rays) and making some parameters into properties to support on-the-fly changes in ray behavior.
     
  39. Quadgnim

    Quadgnim

    Joined:
    Sep 10, 2012
    Posts:
    132
    does anyone know how to delete an arc after it's launched? I'd like to set it to loop, then manually control when to turn it off. I don't see a built in way to do it. I thought maybe the Launcher (helper) would have a kill/delete method, but it doesn't appear to. Any suggestions?
     
  40. Quadgnim

    Quadgnim

    Joined:
    Sep 10, 2012
    Posts:
    132
    Never mind. figured it out with this:

    List<ArcReactor_Launcher.RayInfo> rays = m_arBeamWeapon.launcher.Rays;
    foreach (ArcReactor_Launcher.RayInfo ray in rays) {
    ray.arc.DestroyArc ();
    }

    Two other questions:

    1. I'm using Start=Stick and End=Follow, but the follow is a hard follow. Is there a delayed follow, so the arc will maybe slightly bend a little as the start point moves?

    2. When the arc hit's something, is there a built in method to generate a burn particle effect, or am I on my own to do this?
     
  41. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello.

    1. There was simple inertial algorithm in old versions of ArcReactor, but it was unweildly and performance-hungry, and was deprecated down the road. Instead of it, I added "tangentsFromTransforms" parameter of ArcReactor - you can use it to bend your ray. This option will force arc shapes to be affected by shape transforms orientation. Then just control orientation of your weapon with some inertia to simulate it.

    2. You can use arc reactor events for it. For example of how to use it, you can see ArcReactorDemo3Mirror.cs script. It uses reflection events, but you can use hit events the same way.

    P.S. Just realized that manual wasn't updated, so it's missing tangentsFromTransforms description along with some other minor changes, sorry about that. I'll upload updated version soon to Asset Store and online hosting.
     
  42. Quadgnim

    Quadgnim

    Joined:
    Sep 10, 2012
    Posts:
    132
    Thanks CatPawGames. So far I really like what I'm seeing. One small suggestion.

    In the ArcReactor_Launcher I changed the ArcPrefab to private, and added an ArcPrefabName string as public. I then use Resources.Load (ArcPrefabName) the first time calling launch to set the ArcPrefab. This way I can have one game object with the launcher, and dynamically set my weapon from a config file. Just a small suggestions.
     
  43. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Thanks for suggestion, although I see potential performance problems when there is a lot of instantiated objects with launchers that fire 1-2 times (in RTS, for example). Also it would break existing prefabs of users already using ArcReactor in their project, and generally I try to avoid it.

    Overall, I move in another direction - prefab slot is there mostly for ease-of-use and users without coding experience. First versions had prefab as parameter of Launch method, but it was too complicated for many users. So, I'm currently planning to keep the prefab variable of Launcher and reintroduce parameter with default null into Launch method - so that Launcher can launch any ray you provide, and launch default ray if parameter wasn't provided.
     
  44. Quadgnim

    Quadgnim

    Joined:
    Sep 10, 2012
    Posts:
    132
    I private messaged you as this is a personal optimization idea and I can appreciate having different opinions.

    Onto a more general discussion, I'm looking for some guidance:

    In my game I intend to have very large vehicles shooting at each other from a distance. The arcReactor works beautifully, but when I change the "Distance" in the launcher from 100 to 1000 for example, I noticed the FPS really took a hit. Is there another way to achieve a long distance arc without paying a big penalty? I potentially want 10's of these firing back and forth in an epic battle, but at distance. Any suggestions?
     
  45. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Main cause of CPU usage spikes in long rays are spatial randomizations and oscillations. Randomization overhead is linearly dependent on segment count, so increasing segment length help. If you're planning to use long rays, it shouldn't cause much loss in visual quality (if you don't look at your rays up close). Oscillations overhead depends on both segments and smoothing segments count, so decreasing both should do the trick. In general, reducing number of rays with oscillations is a good idea. I'm trying to optimize it with some caching and other tricks, but I can't give even preliminary ETA on that.
     
  46. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    99
    Hi,

    Just wanted to try your '5-in-1 Demo (Windows)' files, but when I click on the link to get the zip files it says the link is invalid. Do you have a correct one or is your site just down temporarily?
     
  47. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    Hello.

    Sorry for inconvenience, we were in the process of relocating our server. All links should be functional now.
     
    Robdon likes this.
  48. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    I was just trying out the plugin in the newest unity version and it doesn't seem to be functioning correctly anymore. Is this just me or is it broken for the 2018.3 unity?
     
  49. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    436
    It's possible, I didn't perform compatibility testing yet.

    I'll get to it this week, update (if needed) will be available probably sometime next week due to AS review process. If you need fix sooner, please send a message with your invoice # to support email, I'll send you fix manually as soon as it's ready.
     
  50. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    70
    SOLVED

    I had an extra instantiate call right after the first that I didn't notice. I really should just have one of these and enable or deactivate it but good for now. Great plugin - thx!

    Hi,

    I got arc reactor working pretty well. The problem I am having is that the first time I instantiate it, it doesn't show. After the initial instantiate, it works fine - just the first time it does not show.

    Code (CSharp):
    1.  
    2. newray=Instantiate(AC_Ray, shotSpawn.transform.position, shotSpawn.transform.rotation);
    3.  
    4. newray.GetComponent<ArcReactor_Arc>().shapeTransforms[0] = laserSpawn.transform;
    5. newray.GetComponent<ArcReactor_Arc>().shapeTransforms[1] = vectorTarget;
    shotSpawn and laserSpawn are the original point and vectorTarget is the last position.

    Is there any way to preload the effect so that the initial ray shows?

    Thanks,

    Greg
     
    Last edited: Mar 3, 2019