Search Unity

ArcReactor procedural ray generator

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

  1. Kai_Zu

    Kai_Zu

    Joined:
    Dec 14, 2013
    Posts:
    17
    My bad. I had placed the GameObject with the ArcReactor_Arc-component under a transform that had a rotational component. Setting the said GameObject's transform.parent=null and keeping the rotation as Quaternion.identity fixed the problem.
    -Kai_Zu
     
  2. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Thanks for reporting this issue, it should have worked fine even with a rotated parent object, so I'll look into it.
     
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am having issue with controlling the amount of polygons the line renderer is using. To be exact, the number of points the system is generating. Even for a straight line with no oscillation, it is generating far too many points along the way. How do I control them? There doesn't seem to be any obvious parameters for this?
     
  4. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Check out "Segment length" and "Number of smoothing segments" parameters in Size options. These variables control amount of polygons used for ray.
     
  5. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Got this from lvl 11, took a look and there's warnings from obsolete code. Are going to make an update now that the particle stuff has changed in 5.3?
     
  6. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    It's in the plans, update will be uploaded next week.
     
    hopeful and twobob like this.
  7. robymv

    robymv

    Joined:
    Oct 28, 2013
    Posts:
    74
    Hello, congratulations for this asset, I'm trying to implement in my game.
    I have a question, I can stop the effect immediately even if lifetime is greater?
    I mean, when I release the mouse button, I need the effect disappears immediately.
    Thank you and congratulations again for this excellent work.
     
  8. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Thanks!
    You can access elapsedTime variable directly. Setting it to lifetime value when your playbackType is Once will destroy your ray.
     
  9. robymv

    robymv

    Joined:
    Oct 28, 2013
    Posts:
    74
    I'm sorry but I can not understand. Can you give an example, please?
     
  10. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Sure.
    Code (CSharp):
    1. //arc is your ArcReactor component.
    2. arc.elapsedTime = arc.lifetime;
    If you're using Launcher helper script, you can stop all rays launched by it:
    Code (CSharp):
    1. //launcher is your Launcher component.
    2. foreach (RayInfo ray in launcher.Rays)
    3. {
    4.        ray.arc.elapsedTime = ray.arc.lifetime;
    5. }
     
  11. pyloneous

    pyloneous

    Joined:
    Dec 7, 2015
    Posts:
    1
    I had an index exception while testing with overlapping "LaunchRay()" calls.

    in ArcReactor_Launcher.cs

    Line 523.

    Code (CSharp):
    1. rays.RemoveAt(x);
    I changed this line to resolve :

    Code (CSharp):
    1. rays.Remove(destrArr[x]);
     
  12. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Thanks for reporting this, I'll take a look at it.
     
  13. robymv

    robymv

    Joined:
    Oct 28, 2013
    Posts:
    74
    Thank you CatsPawGames and Pyloneous, work perfectly. :)
     
  14. Fulacine

    Fulacine

    Joined:
    Nov 16, 2015
    Posts:
    2
    Where is the video tutorial at? I thought I heard someone talking about it.
    looks super awesome
    just getting a little stuck on getting going with it.
    Im sure that's because of my lack of understanding.
    i would give my left nut for the code to be fully commented.
    However I do like how you laid your code out, and your manual is real nice as well.
    I can't seem to get my laser to shoot from the right transform.position.
    I know I'm missing something small.
    Thanks for all your hard work.
     
  15. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    If you're using Launcher component, just place it to position from which you want to shoot from, then call LaunchRay().

    If you're working with ArcReactor component directly, you need to fill out shapeTransforms or shapePoints arrays - these will determine position and shape of your effect.

    uIntelliSense-compatible comments are definitely in the plans, but its priority is pretty low since manual covers most of use cases.
     
  16. nburlock

    nburlock

    Joined:
    Apr 11, 2013
    Posts:
    65
    How do I control the length of a trail? The trail demo vanishes after a while, but when I use the FireRay_trail in my project, it emits forever and the trail can grow infinitely long.
     
  17. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Use "Truncate By Distance", "Distance Threshold" , "Truncate By Lifetime", "Lifetime Threshold" parameters of ArcReactor_Trail component to control length of your trails.
     
    hopeful likes this.
  18. nburlock

    nburlock

    Joined:
    Apr 11, 2013
    Posts:
    65
    Thanks, I was looking in the arc component. There's so many options I thought I missed seeing it.
     
  19. alemke

    alemke

    Joined:
    Feb 26, 2013
    Posts:
    12
    Hello is it possible to get this asset to work with Oculus Rift?
    stereo rendering for virtual reality?
     
  20. alemke

    alemke

    Joined:
    Feb 26, 2013
    Posts:
    12
    Sometimes it renders properly but when I get too close to an arc it renders the stereo incorrectly
     
  21. nburlock

    nburlock

    Joined:
    Apr 11, 2013
    Posts:
    65
    I have a trail being generated but I can't figure out how to disable so that it vanishes immediately and stops being generated.

    Edit: I also need a method to clear trails, but not disable them as above.

    Edit 2: And I also need it to simulate destroying trails because they are being left behind when the trail object is attached to another object that is under control of a pool manager. When the object is re-spawned, the existing trail continues where it left off.
     
    Last edited: Jan 20, 2016
  22. MakeGames2020

    MakeGames2020

    Joined:
    Nov 14, 2014
    Posts:
    14
    Hi I am using the trail script in your package and im getting some weird results. The trail doesn't render in a stream but rather pulses and I get errors that shoot the trail all over the place. I am getting console errors of:

    IndexOutOfRangeException: Array index is out of range.
    ArcReactor_Arc.LateUpdate () (at Assets/ArcReactor/Scripts/ArcReactor_Arc.cs:1447)

    I have an object following a path using the simple waypoint system so im not too sure if this effects this in anyway but i cant imagine how. I've included a screenshot of what i get. rendererror

    EDIT: Ok so my bad I was using the wrong prefabs now tested it with the proper trials prefabs and it working now
     
    Last edited: Jan 20, 2016
  23. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    1) What VR kit are you using? (I only tested it with Oculus DK2, worked without issues)
    2) Send screenshots with those issues to support email (can be found in publishers description on Asset Store)

    To disable trail, set either time or distance threshold to zero or something like 0.00001f, should do the trick.
     
  24. nburlock

    nburlock

    Joined:
    Apr 11, 2013
    Posts:
    65
    I figured that one out. To clear the trail so that it doesn't resume from the old location, I modified your trail class to make the Initialize() method public. The only remaining issue is that the trail won't reset if the trail gameObject is set inactive. I added a function to de-spawn the object on the next frame after resetting on this frame. I'm still investigating how I can force the trail to reset on the same frame to avoid this messy solution.

    Can I suggest making Initialize() public and even naming it Reset or Clear to make it obvious what it does?

    Edit:
    This code seems to fix the last problem I mentioned above, I added it to ArcReactor_Trail:

    Code (csharp):
    1. public void Clear() {
    2.     segments.Clear();
    3.     segments.Add(new SegmentInfo(transform.position,Time.time));
    4.  
    5.     if (currentArc != null) {
    6.         DestroyImmediate(currentArc.gameObject);
    7.         currentArc = null;
    8.     }
    9. }
     
    Last edited: Jan 21, 2016
  25. slonersoft

    slonersoft

    Joined:
    Feb 7, 2015
    Posts:
    11
    I'm having some trouble using the trail feature for bullet trails. I've parented a game object to the bullet prefab, which is instantiated every time a bullet is fired. The Global Space Transform on the trail script is the gameobject the trail belongs to. The trail works well, except in the first frame, the first few positions on the trail are at world zero, causing some pretty ugly artifacting, and before I was using Global Space Transform, there were even some NaN's in there. Is there some step that I'm missing for this kind of use?

    Screen Shot 2016-01-25 at 7.31.48 PM.png

    Screen Shot 2016-01-25 at 7.31.59 PM.png
     
  26. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Global Space Transform shouldn't be set to the object with trail itself, that's not it's intended use. It should be set to the transform of the space relative to which the trail should be rendered (or, in most scenarios, left empty).

    I'll take a look at the problem you described, most probably the problem is with ArcReactor_Trail script handling instantiating badly.
     
  27. slonersoft

    slonersoft

    Joined:
    Feb 7, 2015
    Posts:
    11
    I kind of had a feeling I was misusing it, but it made it so the trail got destroyed when the bullet did. Without that, it wasn't parented to the bullet and would hang around indefinitely.

    Your hypothesis matches mine. I poked around in your code a bit. I'll let you know if I find anything relevant.

    PS--this tool makes a super cool sizzle piece for my projects, which tend to be lot of glow and no detail since I am no artist.
     
  28. jp2222

    jp2222

    Joined:
    Apr 6, 2013
    Posts:
    17
    Hi,
    Can you please confirm that, unlike LineRenderer, there's no twisting when using lines with multiple vertices? Also, have you any figures regarding performance on mobile (IOS) ?
    Thanks!
     
  29. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Hello.
    ArcReactor uses standard LineRenderers for visualizing arcs, so all inherent problems of LineRenderer are, sadly, present. Perfromance on mobiles heavily depends on usage of lights, all other components of ArcReactor have negligible performance impact.
     
  30. slonersoft

    slonersoft

    Joined:
    Feb 7, 2015
    Posts:
    11
    It may also be worth mentioning that I'm running on OSX. I also have Unity installed on my Windows box. I could see if that makes a difference. I may eventually just make my way to a work-around of skipping rendering the first frame.
     
  31. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    I doubt it would make a difference, it seems like a straight-forward scripting logic error. I think I'll have time during weekend to look at the problem you mentioned.
     
  32. slonersoft

    slonersoft

    Joined:
    Feb 7, 2015
    Posts:
    11
    I noticed that it happens for me even in the trails demo scene (shown below). I'm running Unity 5.3.1f1 on OSX. You may have to up the quality and watch it a few times as YouTube tends to drop frames.

    EDIT #1: I was getting "Invalid AABB a" errors from time to time and was able to fix them by changing line 114 of ArcReactor_Trail.cs to...

    Code (CSharp):
    1. GameObject obj = Instantiate(arcPrefab, transform.position, transform.rotation) as GameObject;
    EDIT #2: I was able to fix the issue by disabling the line renderer until after the first LateUpdate happened. I think there's a render call happening between the two with uninitialized data.

     
    Last edited: Jan 29, 2016
  33. jp2222

    jp2222

    Joined:
    Apr 6, 2013
    Posts:
    17
    Hi again,

    Firstly, thanks for the fast response!
    I've managed to un-twist my lines (see this post: http://forum.unity3d.com/threads/line-renderer-problem.21406/ - The Vector3.MoveTowards code did the trick)

    So, it looks like I'll be buying Arc Reactor soon!

    Just thought you might want to look at that code, in case you want to either include it in your library, or make others aware that there's a way to un-twist, if that's what might put them off purchasing.

    Thanks
    Jason
     
    hopeful likes this.
  34. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Sorry for all of you waiting for update, amount of requests were pretty overwhelming due to participation in level 11 giveaway, but I think I'll roll up updated version by the end of this week.
     
  35. eroberer

    eroberer

    Joined:
    Nov 18, 2013
    Posts:
    8
    Awesome asset, I love the configuration options. I am having one problem that may either be very easy and obvious to fix, or it may be impossible. I added an empty object to my scene and got a bare bones instance of an arc working perfectly between two other objects as soon as I hit the play button in Unity, but the arc isn't showing up at all when I install it on my iPhone 5s.

    I have a couple other particle effects in the scene that seem to emit fewer particles on my iPhone versus the Game window, but at least they show up, but I do not think that is effecting anything. Demo 2 and Demo 5 work on my iPhone, so I am doing something wrong in my own game scene. Any guess?
     
  36. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    My guess is it might be a shader issue. Try using custom material with standard additive shader and see if arc shows or not.
     
  37. eroberer

    eroberer

    Joined:
    Nov 18, 2013
    Posts:
    8
    Alright, I replaced the Arc material with a new one, on which I tried both the Particles/Additive and Mobile/Particles/Additive as the shader, and it's still not showing up on my iPhone. I even added my objects to the Demo 2 scene, and the ARC letters still show up, but my own object with an arc doesn't. It still shows up in the Game window when I click play.

    I'll keep hacking away at it. My project has some other inexplicable things going on, too, like light probes aren't staying visible, and aren't working like I think they're supposed to, and I can't select Linear color...and probably some other stuff I forgot. I'll post here if I figure out what's wrong with this project, or if I figure out it's a real Arc bug (unlikely).
     
  38. eroberer

    eroberer

    Joined:
    Nov 18, 2013
    Posts:
    8
    Okay, to get it to work on my iPhone, under Size Options for my arc, I had to change "Segment Length," "Number of smoothing segments," and "Min number of segments" to 1, 5, and 1. They were 0, previously, and I doubt the actual number matters, that's just what I copied from a different working arc.

    I'll do some more debugging later tonight, but that's what I've found so far. I think this was causing a division by 0. I was getting a null object reference message in the Xcode debugger, so I'm a little confused. Regardless, even with the values I mentioned above set to 0, the arc would show up in the Unity Game window, but not on the iPhone.

    Anyway, it still looks good, and all the Demos work on the iPhone, for anyone curious at home. Still an awesome asset, like I said above!
     
  39. eroberer

    eroberer

    Joined:
    Nov 18, 2013
    Posts:
    8
    Alright, it's the "Segment Length" and "Min number of segments" that I can't have set to 0 at the same time, for some reason. Below is the debug output that I get. The null reference error is repeated over and over again until I shut it down.

    OverflowException: Arithmetic operation resulted in an overflow.
    at ArcReactor_Arc.Initialize () [0x00000] in <filename unknown>:0
    at ArcReactor_Arc.CalculateShape () [0x00000] in <filename unknown>:0
    at ArcReactor_Arc.Start () [0x00000] in <filename unknown>:0
    (Filename: currently not available on il2cpp Line: -1)

    NullReferenceException: A null value was found where an object instance was required.
    at ArcReactor_Arc.LateUpdate () [0x00000] in <filename unknown>:0

    It looks like this line may the culprit, and now I can't see how it works in the game window:
    (shapeLength/(arcs[n].sizeOptions.segmentLength*sizeMultiplier)

    CORRECTION: I can't have both "Segment Length" and "Min number of segments" set to 0. One of them has to be above zero, apparently. I'm pretty much done debugging this unless setting one of them to non-zero somehow causes a problem. I still don't see how that calculation above doesn't throw an error when "Segment Length" is 0, so I'd love an explanation if you're up for it Cats.
     
    Last edited: Feb 6, 2016
  40. jp2222

    jp2222

    Joined:
    Apr 6, 2013
    Posts:
    17
    Hi again,
    I'm about to swap over from using the existing standard Unity LineRenderer to ArcReactor.
    Can you give any hints/tips on what would be involved here, once installed? How easy is it to swap over? Which sample code would you recommend, etc..

    Just want to make the process as painless as possible,
    Thanks!
     
  41. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Depends on your intended use. Overall I recommend using Launcher helper component if you're using it for weapons. In other cases, you can use Arc component directly, controlling it should be pretty easy - consult manual for parameters and their description.

    Supplied rays are mostly intended for use in weapons effects, but it's a good idea with auto-freeze option. I'll include it in the coming update.

    That would be quite hard to do since Arc elements aren't really "elements", it's just groups of thematically connected options. I'll see what groups I can disable without any problems and add flags to them.
     
  42. jp2222

    jp2222

    Joined:
    Apr 6, 2013
    Posts:
    17
    Hi again!

    Not sure if I've found a bug in the sorting layer code or not.
    I change the sorting layer via the "Custorm Sorting" tickbox and the Sorting Layer Name string. However, this didn't change the layer of the LineRenderer.
    On going through the code, I saw that the lrends[n].sortingLayerNames wasn't getting modified (it was getting called, but still said "Default", no matter what string I passed it. Checked both from within the debugger and via Debug.Log calls.)

    To change the layer, I had to do this instead:
    rayLineRenderer.layer=LayerMask.NameToLayer(sortingLayerName);

    This made the line appear on the correct layer (in my case, in front of the main game sprites, so I could actually see it!). However, I also had to duplicate that line for the particles too:
    partGameObject.layer=LayerMask.NameToLayer(sortingLayerName);

    Again, not sure if it's just me. But it fixed it here, so that I can actually set the layer as I'd expect.
     
  43. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Looks like a mistake on my part. SortingLayerNames should logically be ReadOnly, so don't know why I tried modifying it. I'll expose layer variable in the update, your fix should work for now.

    Edit: Ok, I got confused a little. Sorting Layers are independent entity from usual Unity Layers, so it's normal behavior, no fix necessary. If you want to change layer of linerenderer, I'll add additional variable.
     
    Last edited: Feb 14, 2016
  44. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Well, it's not "for some reason" you can't have "Segment Length" set to 0, it's very obvious that segment length of zero would cause all sorts of trouble. I'm surprised too that it worked on any platform. It's not a bug, but I'll add zero check on start to give a warning.
     
  45. puargs

    puargs

    Joined:
    Apr 30, 2013
    Posts:
    10
    I was having the same problem as Slonersoft, artifacting on trails during the first frame or two. The problem was fixed by the same solution as him, but he didn't post any code so I thought I'd post some here in case it helps anyone (or in case you want to integrate it into your product permanently).

    In ArcReactor_Arc.cs:
    In variable declarations at the top, I added:
    Code (CSharp):
    1. public bool lateUpdatedCalled = false;
    Then in Start(), in the for loop that declares the arcs (starts about line ~1159), I added this as the LAST line in the for loop:
    Code (CSharp):
    1. lrends[n].enabled = false;
    Then as the very last line in LateUpdate(), I added this:
    Code (CSharp):
    1. if (!lateUpdateCalled)
    2.         {
    3.             lateUpdateCalled = true;
    4.             for (int c = 0; c < lrends.Length; c++)
    5.             {
    6.                 lrends[c].enabled = true;
    7.             }
    8.         }
    This fixed any artifacting for me with trails.
     
    hopeful likes this.
  46. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    Thanks for the code! I just finished fixing Trail component instead of Arc, but I appreciate it. I'll take a look at what solution will be better and include it in the next version.
     
    puargs likes this.
  47. puargs

    puargs

    Joined:
    Apr 30, 2013
    Posts:
    10
    Also as a note, ParticleSystem IsAlive() is currently broken in most current version of unity (per http://forum.unity3d.com/threads/unity-5-3-1p1-particles-system-isalive-not-working.375911/ it's a confirmed bug). If anyone else is having problems with the emitters sticking around in your scene using some of the trail prefabs, you can just change your ArcReactor_EmitterDestructor.cs to the following :
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System;
    4.  
    5. public class ArcReactor_EmitterDestructor : MonoBehaviour {
    6.  
    7.     public ParticleSystem partSystem;
    8.     public DateTime endTime;
    9.     public bool dateTimeStarted = false;
    10.  
    11.     // Update is called once per frame
    12.     void Update ()
    13.     {
    14.         if (!dateTimeStarted)
    15.         {
    16.             dateTimeStarted = true;
    17.             endTime = DateTime.Now.AddSeconds(5);
    18.         }
    19.  
    20.         if (!partSystem.IsAlive() || (dateTimeStarted && DateTime.Now > endTime))
    21.             Destroy(gameObject);
    22.     }
    23. }
    This is of course assuming that you can't wait until the next build, AND that you don't have any emitters that last longer than 5 seconds after death (if you do, just change the seconds to a higher number).
     
  48. Superrodan

    Superrodan

    Joined:
    Nov 10, 2013
    Posts:
    10
    Hi there. I'm using your rays as lasers that should be toggle-able on or off. For their lifetime I put an absurdly high amount so that they never actually turn off. In code I have been using
    launcher.LaunchRay();
    to turn on the rays. I read a previous post you made about how to disable them instantly using code and so and I tried this code:

    Code (CSharp):
    1.     public void TurnOffRay()
    2.     {
    3.         Debug.Log ("GOTHERE");
    4.         foreach (ArcReactor_Launcher.RayInfo ray in launcher.Rays)
    5.         {
    6.             Debug.Log ("GOTHERE1");
    7.             ray.arc.elapsedTime = ray.arc.lifetime;
    8.         }
    9.     }
    The rays are not turning off when I call this. I am seeing the first debug log message so I know this is being called, but I'm not seeing the second one. Am I making an assumption or doing something wrong that is easy to see from this code?
     
  49. ncho

    ncho

    Joined:
    Feb 1, 2014
    Posts:
    99
    Any advice for integrating this with UFPS? I am quite lost in this regard. Where do I add the components for this to work? I want a weapon that shoots a continuous beam as long as the mouse button is held. Would appreciate any suggestions.
     
  50. CatsPawGames

    CatsPawGames

    Joined:
    Jun 4, 2014
    Posts:
    443
    I have no experience with UFPS, so I can't help you much with this. But, general advise is to parent Launcher component to your weapon and call its Launch() method on fire event, and stop all rays(get Rays array) on stop firing event. Damage handling etc. can be done through UFPS, or you can use Launcher messages.

    If you're not seeing second debug message, it means that your Rays array is empty. Make sure that ArcReactor_Launcher is the launcher you use and not, for example, original that you instantiate from.