Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

[X-WeaponTrail]The best weapon trail solution for unity.

Discussion in 'Assets and Asset Store' started by shallwaycn, Aug 18, 2014.

  1. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Last edited: Jun 20, 2019
  2. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    That certainly looks impressive. Does it work with Free or is it Pro only?
     
  3. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    It works with Unity Free, But the distortion effect only works with Unity pro:)
     
  4. Gunhi

    Gunhi

    Joined:
    Apr 18, 2012
    Posts:
    294
    looks fantastic, can't wait!
     
  5. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    This looks really cool. Thanks for sharing it :)
     
  6. b4c5p4c3

    b4c5p4c3

    Joined:
    Jan 4, 2013
    Posts:
    537
    Looks very cool
     
  7. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    red2blue likes this.
  8. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Very cool, will give it a try. Thanks man!
     
  9. Maya2001

    Maya2001

    Joined:
    Jul 4, 2014
    Posts:
    5
    I think he took it off in asset store. Can't download >_<
     
  10. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    8,148
    Really cool, thanks for this

    Reminds me the effect in Dust Elysian Tale and is indeed one of the best i have seen
     
  11. OutSpoken_Gaming

    OutSpoken_Gaming

    Joined:
    Oct 14, 2013
    Posts:
    91
    You need Unity 4.5.2 or higher to download. I just checked and its still there and downloadable.
     
  12. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    8,148
    Sometime i wish free assets had a price :), i cant download it too, while paid ones can be downloaded if you go to the list menu.

    I have to install Unity 4.5.2 to another windows, download and delete it. Or upgrade to Unity 4.5.2 and hope none of my work has any problems.

    Is there any known trick to bring the free assets to the list menu ?
     
  13. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    43
    Hey, you just updated the X-WeaponTrail in the Asset Store and while I GREATLY appreciate the work you put into it to make it more efficient, I desperately need access to the old version so that I can implement SortingLayers for a 2d game.

    Would it be possible for me to get the package from you? Thank you very much!
     
  14. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Hi, I'm sorry I didn't realize that the new version is not able to use with 2d sprites.
    I'll submit a fixed version quickly, you can download it in the next week at the latest.
     
  15. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    43
    The issue is that when using Graphics.DrawMesh you don't have any way to set the sorting layer. A lot of people have requested the feature and it's in review.. but for now, they're no way to allow sorting layers with meshes unless you're using mesh components and such like you were before

    I like the new more efficient version though...
     
  16. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Thanks for the remind.

    I'll make a new option "Use with 2D", if enabled, additional mesh object will be created, otherwise use DrawMesh() to renderer the trail.
     
  17. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    105
    Looks like this has some compatibility issues with Xffect Editor? I'm throwing compile errors related to Xft namespace.
     
  18. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    X-weapon trail is included in Xffect editor package by default, please delete the EnhancementTools/XWeapontrail folder in the xffect package, I'm sorry for this inconvenience.
     
  19. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    105
    Haha, no problem. Thank you for your support. Will you ever add any features to XWeaponTrail such as color over time?
     
  20. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Yes, it's still a very simple trail system. I'll keep improving it in my spare time:)
     
    Eluem likes this.
  21. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    43
    The nice thing is that, since the package actually includes the source, it's fairly easy to add those types of features on your own, if you need them now.

    I really appreciate how simple and streamlined it is while producing some very nice and heavily customizable trails.

    The only thing I'd like to improve that I can't figure out.. is how to get the trail to be more flush with the start/end line so that there's less/no gap between the weapon and the trail.
     
  22. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    43

    I have a little work around that I managed to get together. It might not work for everyone, though.

    Graphics.DrawMesh draws into the Default sorting layer.. so, if you want to place anything that you want to be able to sort above/below the weapon trail dynamically into that layer (i.e. a player where you might have overhead chops vs sweeping slashes) you can get them meshes to render above or below the objects in that layer based on the z-axis (assuming you're using xy as your 2d plane.

    However, there's still one annoying issue. For some reason, the mesh vertexes themselves aren't taken into account when checking distance layering with sprites. If you use Graphics.DrawMesh and pass an actual position in, that does work. So, I went through and changed all the places where you set a value in the m_snapshotList and replaced the z-axis for the PointStart/End with a 0. Then, I pass a new Vector3(0, 0, _gameObject.Transform.position.z) into the Graphics.DrawMesh.

    This will effectively work the same way (at least in 2d it does), except that it will layer correctly, allowing for dynamic animations that change the z-axis positioning at will to change where the mesh is in the default layer
     
  23. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    This seems to work, but I'd rather waiting for the official support for drawing mesh with sorting layer.
    Actually I've just submitted a new version which gives "Use With 2D Sprite" option to create mesh object to render the trail.

    Thank you again for the kind suggestion!
     
    Eluem likes this.
  24. Eluem

    Eluem

    Joined:
    Apr 13, 2013
    Posts:
    43
    Thank you for kindly making and releasing this code to the public. It works so well and it's really really good.

    I would like to remind you of one last thing. If I'm not mistaken, even if you do use a mesh object to render the trail, the way you were doing it in the previous version still had the issue of not ordering the mesh correctly WITH IN a layer. It did grant the ability to set the sortingLayer, which was very nice.. but it still didn't properly set the render order with in the layer.

    The reason this would happen is due to the fact that your actual GameObject's position is what's used to determine the order in the layer with regards to 2d render sorting. With your previous version, your GameObject that held the mesh was actually locked into one position at the origin, I believe. Then your mesh was generated in a similar way to how it is now.. and the local position relative to that object was how it was rendered.

    Similarly, when you use Graphics.DrawMesh, it treats the matrix/position as the "GameObject" position when determining render order.

    I have two possible solutions, one is more robust but requires more math:
    1) This one requires more work/math to get it to work correctly. Instead of creating a new GameObject which will sit at the origin point and never move so that it can house a Mesh component, generate the mesh straight into the GameObject with the XWeaponTrail component. Then use the LocalPosition of the Start/End points to generate your mesh trail instead of their global positions. Now the mesh being rendered has a physical location that lines up with the containing GameObject and it's render order will be based on the XWeaponTrail's gameObject's position, instead of always staying at the origin.

    This one requires a bit more work because your whole system is based around assuming that you're working from the origin.

    2) You can make it so that when you're in 2D mode, in addition to using a mesh component instead of Graphics.DrawMesh, you choose which plane you're playing your 2d game in (XY, XZ, YZ). Then, based on that, you use the axis which is prependicular to that plane and make it so that the mesh is always generated with a 0 on that plane for all vectors and you make sure that the object that contains the mesh tracks the position of the XWeaponTrail along that axis.

    This will allow the user to control the render order within a sorting layer along that axis.

    This is basically what I did with the Graphics.DrawMesh to get it working (except that even with this tweak, it's still stuck in the Default layer).


    I'm pretty sure that even when you use a mesh object, it still has this issue.

    Thanks for your time! :D
     
  25. MikeR_UFG

    MikeR_UFG

    Joined:
    Dec 1, 2014
    Posts:
    12
    Minor point, but shouldn't the mMeshObj (allocated in Start()) be cleaned up when the XWeapon gameobject is destroyed? Perhaps just adding:

    void OnDestroy()
    {
    GameObject.Destroy(mMeshObj);
    mMeshObj = null;
    }
     
  26. daybreaker93

    daybreaker93

    Joined:
    Jun 11, 2014
    Posts:
    71
    Love your work! Easy to integrate.

    One question though, is there any way to make the trail render at the exact frame?

    Currently it's late by a frame, right?

    trail.gif
     

    Attached Files:

  27. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Hi

    This is a known issue because the unity's DrawMesh() function cant render the mesh immediately.

    Sadly currently I can't find a solution, if anyone has some advises please tell me.:(
     
  28. wightwhale

    wightwhale

    Joined:
    Jul 28, 2011
    Posts:
    390
    One of my sword animations plays too quickly and the path of the x-weapon trail gets messed up. Is there any way to fix this? I've tried raising the FPS and the granularity but neither seem to help.
     
  29. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    based on the description, maybe you didn't deactivate the trail when the animation finished?

    FAQ:
    Is it possible to stop the weapon trails when the attack animation is not playing?

    Yes, you need to call the API in the XWeaponTrail.cs:
    call Activate() when you want to turn the trail on.
    call Deactivate() when you want to turn the trail off.
    Please refer the XWeaponTrailDemo.cs to learn more.
     
  30. battlemasterz

    battlemasterz

    Joined:
    Nov 3, 2014
    Posts:
    2
    is it possible to pay for an older version of xweapontrail?

    i have a project made using unity 5.4.2
     
  31. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Sorry for this inconvenient, I don't keep an older version of xweapontrail.
    If you really need it you can copy it from unity 5.5 to unity 5.4.2, and re-assign the script there should be no problem.:)
     
  32. Yamoc4

    Yamoc4

    Joined:
    Jul 26, 2013
    Posts:
    10
    Hey great plugin :). I'm trying to slow down time on the trail effect. In my game which I have a time multiplier which I multiply x Time.Deltatime to get the slowing effect rather than using unity's native timescale option.

    I tried this approach on this plugin (I only found 2 lines using deltatime) and it was unsuccessful. Is there a way to get the desired effect? Thanks!
     
  33. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    You can try to add this code behind the UpdateHeadElem(); function in Update()
    Code (CSharp):
    1.             UpdateHeadElem();
    2.  
    3.  
    4.             mElapsedTime += Time.deltaTime;
    5.             if (mElapsedTime < UpdateInterval) {
    6.                 return;
    7.             }
    8.             mElapsedTime -= UpdateInterval;
    this should helps.
     
  34. Yamoc4

    Yamoc4

    Joined:
    Jul 26, 2013
    Posts:
    10
    This got it working :). Thanks!
     
  35. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    405
    shallwaycn,

    Since I started using pooled prefabs for my weapons, I'm having a problem with X-Weapon Trail.

    Here is what is happening:
    When I start the game, my weapons are not equipped but they are spawned as deactivated prefabs at world space position 0,0,0. (This is the default use case of PoolManager). I Activate and Deactivate the weapon trails per the API when I swing my weapon. When I equip my weapons, they are activated and attached to the player. Upon the very first sword swing, after my player is equipped with weapon in hand, when I first Activate the weapon Trail, the weapon Trail flies/spreads from world space position 0,0,0 to the weapon local position. After that very first activation, the weapon trails are all correct and start at the local space weapon position.

    I have my weapon trails childed to my weapon mesh gameobject exactly as you do in your demo scene.

    It's only on the very first activation of the weapon trail that the trail flies across the screen from world space location 0,0,0 to my player's local position and the local position of the weapon. This is because that's where my weapons start as deactivated pooled prefabs. For some reason X-Weapon Trail is grabbing that first world space location and using that as it's beginning draw location and it only occurs the first time you swing the sword.

    My guess is you don't see this in your demo because your weapons start already attached to your player and you are not using weapons that are pooled prefabs.

    Any help would be appreciated. Also I am using the current version of Unity and X-Weapon Trail.

    Thanks
    Allan
     
  36. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    405
    I think I solved my own problem. In the start method of my weapons, I call Init() and Deactivate() on all of my weapon trails. That seemed to fix my problem.
     
  37. FullGrain

    FullGrain

    Joined:
    Jul 30, 2017
    Posts:
    1
    Is this okay for use in a commercial product?
     
  38. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Yes, all of the assets on the asset store are covered by the same license:
    https://unity3d.com/cn/legal/as_terms
     
  39. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Hi,
    sorry for the late reply.

    glad you solved this problem and thanks for sharing:)
     
  40. maximilianahead

    maximilianahead

    Joined:
    Mar 30, 2015
    Posts:
    9
    Hi, Great assets dev^^
    Can I remove a trail at any timing?

    1.Combo1 Activate
    2.Combo1 Deactivate
    3.Move
    4.Combo1 Activate <= I want to remove previous Combo1 trail

    The trail that last state show again when I activate trail.
    This is a little troublesome in my project.
    You can easily check by calling Stop method before playing animation at XWeaponTrailDemo.cs.

    It did not happen in ver 1.3.0.
     
  41. maximilianahead

    maximilianahead

    Joined:
    Mar 30, 2015
    Posts:
    9
    and one more thing,
    It exception emit when PointStart, PointFinish at XWeapontrail.cs field is unset until instantiated.
    Because the Init called with OnEnable.
    so my xweapontrail prefab must deactivated to not call Init.
    It is slightly inconvenient.
     
  42. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Hi,

    Thanks for the feedback, can you tell me are you using XWeaponTrail in 2D project? (the "Use With 2D" option is checked or not)

    If so, I'm already aware of this issue and will submit a fix soon.

    If not please give me more details because I can't reappear the issue you mentioned:(
     
    Last edited: Feb 26, 2019
  43. maximilianahead

    maximilianahead

    Joined:
    Mar 30, 2015
    Posts:
    9
    Yes, "Use With 2D" option is checked.

    Is there a method to easily remove the trail?
    The trail will remain last deactivate point.
    This is no problem but in my project, I want to remove the previous all trail at the Activate call.


    Edit:
    ah, the reason is that Animation.Play and Activate are called at the same timing, because the positions of PointStart and PointEnd have not been updated by animation yet.
    I misunderstood. sorry^^;
    I will wait for fixes bugs you already aware of.
     
    Last edited: Feb 26, 2019
  44. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    405
    I think you introduced a bug in version 1.4.2. I noticed after updating to 1.4.2 I was having the same problem I had reported earlier in this forum. If you scroll up, you can see my issue. It has to do with the fact that in your demo you already have the weapons attached to the character bones. This is not realistic for a production game where weapons and inventory will be added and removed from a character throughout the game and oftentimes these weapons are pooled and instantiated at other world positions for storage/pooling. (Their starting positions when instantiated are not the starting positions when they are used in the game) In previous versions, I was able to fix my issue by calling .Init and .Deactiviate on all XWeaponTrails in the Awake() method on my weapons.

    I was able to find the problem by comparing XWeaponTrail.cs versions 1.4.2 to 1.4.1

    In the Start() method on XWeaponTrail.cs in 1.4.2, you removed the following line:
    mInited = false;

    I don't know why you removed that line but by removing it, it causes the trail starting points to be stored when the weapon is first brought into a scene. And on the first swing, the trail flies across the screen from wherever that starting point was. All swings after the first one are correct.

    I put the line back into 1.4.2 and now I call .Init() and .Deactivate() in the Awake() method on my weapons, the trails start correctly at the weapon position instead of at the instantiate position.

    Thanks
    Allan
     
    shallwaycn likes this.
  45. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Hi Allan,

    Thanks for the feedback, I didn't realize this problem before.

    I removed the "mInited = false;" in Start() is because I found it sometimes cause the trail mesh to be inited twice which has no influence on functionality.

    I will submit a fix soon.

    Thanks

    Shallway
     
  46. Shiyao

    Shiyao

    Joined:
    Nov 27, 2013
    Posts:
    23
    Hi shallwaycn, Does this trail work with LWRP on mobile platform?
     
  47. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Yes it works with LWRP.
    But the shaders are broken so you can't see anything in the demo.
    To use with LWRP or other SRP please follow these instructions below:

    1, disable the "Bkg" object in the scene
    2, Find "WeaponTrail_simple" game object, and check on the "Use With SRP" option in the inspector.
    3, play the demo then you can see the trail.

    and please note the screen distortion shader does not work with SRP.
     
  48. Shiyao

    Shiyao

    Joined:
    Nov 27, 2013
    Posts:
    23
    Hi shallwaycn, great work on XWeapon Plugin, It runs very well on the windows platform, However, when I builded it on android platform with lwrp. It will crash app on my phone. I also tested your demo on android platform, it ran well with build-in render pipelines, but it crashed again with lwrp.

    Wish you can fix this problem, we need lunch our game demo before 20th June. This weapon tail FX is very important for us.
    upload_2019-6-9_16-2-44.png upload_2019-6-9_16-4-37.png
     
  49. shallwaycn

    shallwaycn

    Joined:
    Apr 3, 2012
    Posts:
    199
    Hi,

    I'm sorry but could you show me some crash log?

    As far as I know the distortion effect you attached does not support LWRP...

    Also please make sure the "Use With SRP" option is checked before testing.

    Regards,
     
  50. Shiyao

    Shiyao

    Joined:
    Nov 27, 2013
    Posts:
    23
    Sorry, Bro. After we make few test, we found that crash from shader graph. Thanks for quick response, and Shader graph is suck. by the way, there is a way to make distortion effect on lwrp. you can use _CameraOpaqueTexture.
     
unityunity