Search Unity

Realistic effects pack [Asset Store]

Discussion in 'Assets and Asset Store' started by kripto289, Apr 1, 2014.

  1. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Hello, Mr. mojao :)
    It does not look very nice. Works only refraction. Distortions do not work.


     
    Last edited: Jun 12, 2014
  2. mojao

    mojao

    Joined:
    Sep 2, 2013
    Posts:
    47
    Oh,thanks Mr.kripto289!
    I appreciate your kindness,Thank you very much!

    Ok,I understand. but water effect also very sweet.
    I was impressed your effectpack v2 too,so i was ambivalent which to buy, but i dicide to buy your pack v2( i will buy pack v1 too when i get next salaly!)

    thanks a lot!
     
  3. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    You're welcome :)
    By the way, do you game for PC?
    Because Unity terrible problems with distortion on mobile with "forward rendering". FPS never more than 3 frames on any mobile device.
    Distortions are faster on "deferred rendering", but still pretty low FPS (on poverVR 544mp2 about 25fps).
    And the water without distortion disgusting.
     
  4. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Effects are topnotch, but generates exception errors in iOS. The error below is from running the provided demo scene.


    Code (CSharp):
    1. ExecutionEngineException: Attempting to JIT compile method 'System.Linq.OrderedEnumerable`1<System.Collections.Generic.KeyValuePair`2<UnityEngine.GameObject, single>>:GetEnumerator ()' while running with --aot-only.
    2.  
    3.   at System.Linq.Enumerable.ToDictionary[KeyValuePair`2,GameObject,Single] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector, IEqualityComparer`1 comparer) [0x00000] in <filename unknown>:0
    4.   at System.Linq.Enumerable.ToDictionary[KeyValuePair`2,GameObject,Single] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector) [0x00000] in <filename unknown>:0
    5.   at EffectSettings.RegistreActiveElement (UnityEngine.GameObject go, Single time) [0x00000] in <filename unknown>:0
    6.   at CollisionActiveBehaviour.Start () [0x00000] in <filename unknown>:0
    7. (Filename:  Line: -1)
     
  5. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    BTW, I think the cause is the eventHandlers. I remember reading about this issue somewhere on the forums.
     
  6. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Alas, I have no way to test for ios. Most likely this is due to the fact that ios not the JIT and AOT compilation.
    There's nothing I can help, most likely you will have to write a script for a callback.
     
  7. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Just a quick note ... I used your portal effects in my Windows Store game. The effect works great in my work-in-progress Windows Phone version too.

    Here's a screenshot:

    screenshot_06142014_204612 - Copy by raj_dhillon, on Flickr
     
  8. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207

    That's a shame. If you are not going to fix it, then I suggest you add a disclaimer in your asset store listing that says "iOS is not supported." At least others will know.
     
  9. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    I primarily sell visuals. Scripts is an addition that will help simplify the writing game.
    Ios.xamarin not support "generics" variable types.
    The problem is only in the script "EffectSettings" and the use of dictionaries.
    Soon I'll post the script without the use of dictionaries. Hope this helps.
     
  10. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    That "effectSettings" script is rewritten:
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3.  
    4. public class EffectSettings : MonoBehaviour
    5. {
    6.   public float ColliderRadius = 0.2f;
    7.   public float EffectRadius = 0;
    8.   public GameObject Target;
    9.   public float MoveSpeed = 1;
    10.   public float MoveDistance = 20;
    11.   public bool IsHomingMove;
    12.   public bool IsVisible = true;
    13.   public bool DeactivateAfterCollision = true;
    14.   public float DeactivateTimeDelay = 4;
    15.   public LayerMask LayerMask = -1;
    16.  
    17.   public event EventHandler<CollisionInfo> CollisionEnter;
    18.   public event EventHandler EffectDeactivated;
    19.  
    20.   private GameObject[] active_key = new GameObject[100];
    21.   private float[] active_value = new float[100];
    22.   private GameObject[] inactive_Key = new GameObject[100];
    23.   private float[] inactive_value = new float[100];
    24.   private int lastActiveIndex;
    25.   private int lastInactiveIndex;
    26.   private int currentActiveGo;
    27.   private int currentInactiveGo;
    28.   private bool deactivatedIsWait;
    29.  
    30.   public void OnCollisionHandler(CollisionInfo e)
    31.   {
    32.     for (int i = 0; i < lastActiveIndex; i++)
    33.     {
    34.       Invoke("SetGoActive", active_value[i]);
    35.     }
    36.     for (int i = 0; i < lastInactiveIndex; i++)
    37.     {
    38.       Invoke("SetGoInactive", inactive_value[i]);
    39.     }
    40.     var handler = CollisionEnter;
    41.     if (handler != null)
    42.       handler(this, e);
    43.     if (DeactivateAfterCollision && !deactivatedIsWait)
    44.     {
    45.       deactivatedIsWait = true;
    46.       Invoke("Deactivate", DeactivateTimeDelay);
    47.     }
    48.   }
    49.   public void OnEffectDeactivatedHandler()
    50.   {
    51.     var handler = EffectDeactivated;
    52.     if (handler != null)
    53.       handler(this, EventArgs.Empty);
    54.   }
    55.  
    56.   public void Deactivate()
    57.   {
    58.     OnEffectDeactivatedHandler();
    59.     gameObject.SetActive(false);
    60.   }
    61.  
    62.   private void SetGoActive()
    63.   {
    64.     active_key[currentActiveGo].SetActive(false);
    65.     ++currentActiveGo;
    66.     if (currentActiveGo >= lastActiveIndex) currentActiveGo = 0;
    67.   }
    68.  
    69.   private void SetGoInactive()
    70.   {
    71.     inactive_Key[currentInactiveGo].SetActive(true);
    72.     ++currentInactiveGo;
    73.     if (currentInactiveGo >= lastInactiveIndex) {
    74.       currentInactiveGo = 0;
    75.     }
    76.   }
    77.  
    78.   public void OnEnable()
    79.   {
    80.     for (int i = 0; i < lastActiveIndex; i++)
    81.     {
    82.       active_key[i].SetActive(true);
    83.     }
    84.     for (int i = 0; i < lastInactiveIndex; i++)
    85.     {
    86.       inactive_Key[i].SetActive(false);
    87.     }
    88.     deactivatedIsWait = false;
    89.   }
    90.  
    91.   public void OnDisable()
    92.   {
    93.     CancelInvoke("SetGoActive");
    94.     CancelInvoke("SetGoInactive");
    95.     CancelInvoke("Deactivate");
    96.     currentActiveGo = 0;
    97.     currentInactiveGo = 0;
    98.   }
    99.  
    100.   public void RegistreActiveElement(GameObject go, float time)
    101.   {
    102.     active_key[lastActiveIndex] = go;
    103.     active_value[lastActiveIndex] = time;
    104.     ++lastActiveIndex;
    105.   }
    106.  
    107.   public void RegistreInactiveElement(GameObject go, float time)
    108.   {
    109.     inactive_Key[lastInactiveIndex] = go;
    110.     inactive_value[lastInactiveIndex] = time;
    111.     ++lastInactiveIndex;
    112.   }
    113. }
    114.  
    115. public class CollisionInfo : EventArgs
    116. {
    117.   public RaycastHit Hit;
    118. }

    Try the test and let me know if there are any errors?
     
  11. Tendus

    Tendus

    Joined:
    Jun 26, 2014
    Posts:
    2
    Hey, I'm having a small issue with the first shot (the red laser effect). I can't get it to fire correctly consistently. Most the time it goes from the world point (0,0,0) to where I'm trying to fire it from. I've got it setup where it instantiates the effect at the fire point, creates a direction, creates an empty game object in that direction from the firing point and sets the move speed.
     
  12. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    This occurs when "raycast" misses (shoot "raycast" necessary to clarify the point of impact).
    Increase "moveDistance". (e.g. 500)
    Can also be replaced in the script "lineRendererBehaviour" here this method:
    Code (CSharp):
    1. void InitializeDefault()
    2.   {
    3.     renderer.material.SetFloat("_Chanel", currentShaderIndex);
    4.     ++currentShaderIndex;
    5.     if (currentShaderIndex == 3) currentShaderIndex = 0;
    6.     line.SetPosition(0, tRoot.position);
    7.     if (StartGlow != null) StartGlow.transform.position = tRoot.position;
    8.     if (IsVertical)
    9.     {
    10.       if (Physics.Raycast(tRoot.position, Vector3.down, out hit))
    11.       {
    12.         line.SetPosition(1, hit.point);
    13.         if (HitGlow != null) HitGlow.transform.position = hit.point;
    14.         if (GoLight != null) GoLight.transform.position = hit.point + new Vector3(0, LightHeightOffset, 0);
    15.         if (Particles != null) Particles.transform.position = hit.point + new Vector3(0, ParticlesHeightOffset, 0);
    16.         if (Explosion != null) Explosion.transform.position = hit.point + new Vector3(0, ParticlesHeightOffset, 0);
    17.       }
    18.     }
    19.     else
    20.     {
    21.       tTarget = effectSettings.Target.transform;
    22.       var targetDirection = (tTarget.position - tRoot.position).normalized;
    23.       if (Physics.Raycast(tRoot.position, targetDirection, out hit, effectSettings.MoveDistance + 1, effectSettings.LayerMask)) {
    24.         var direction = (tRoot.position + Vector3.Normalize(hit.point - tRoot.position) * (effectSettings.MoveDistance + 1)).normalized;
    25.         line.SetPosition(1, hit.point - effectSettings.ColliderRadius * direction);
    26.         var particlesOffsetPos = hit.point - direction * ParticlesHeightOffset;
    27.         if (HitGlow!=null) HitGlow.transform.position = particlesOffsetPos;
    28.         if (GoLight!=null) GoLight.transform.position = hit.point - direction * LightHeightOffset;
    29.         if (Particles!=null) Particles.transform.position = particlesOffsetPos;
    30.         if (Explosion!=null) Explosion.transform.position = particlesOffsetPos;
    31.         OnEffectOnHitObject();
    32.       }
    33.       else {
    34.         line.SetPosition(1, tTarget.position);
    35.         if (HitGlow!=null) HitGlow.transform.position = tTarget.position;
    36.         if (GoLight != null) GoLight.transform.position = tTarget.position;
    37.         if (Particles != null) Particles.transform.position = tTarget.position;
    38.         if (Explosion != null) Explosion.transform.position = tTarget.position;
    39.       }
    40.     }
    41.  
    42.     effectSettings.OnCollisionHandler(new CollisionInfo { Hit = hit });
    43.   }
     
    Tendus likes this.
  13. Tendus

    Tendus

    Joined:
    Jun 26, 2014
    Posts:
    2
    Alright, thanks man. Its working now
     
  14. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207

    Script works great! Thanks. For what it's worth, I appreciate your point about selling visual effects and not scripts, but speaking as a person who buys a lot of assets (especially particle effects), I gotta tell you the quality of your scripts is an big differentiator.
     
  15. Paarthurnax

    Paarthurnax

    Joined:
    Feb 12, 2013
    Posts:
    34
    Hi Kripto,

    I have a question. Is it possible to scale down the effects? The way my game is built the effects are too big. (It's still in early prototype so I could scale my objects but i'd prefer to scale the effects if possible....I'm not a programmer so sorry if the question seems silly. My programmer is away at the moment, so i'm stuck on my own for now. I can sort of get my way around...So how would I go about scaling them in the scripts? If possible.
     
  16. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Hi,
    To scale usually enough to change "start size" of particles system inside the prefab.
    Effects for "shield" is enough to change prefab parameter "scale"
     
  17. drthirteen

    drthirteen

    Joined:
    Oct 12, 2013
    Posts:
    3
    I have a problem using those effects for a first-person shooter.
    I am using the code example that is in the documentary for the target.
    But it doesnt notice a collision when it collides with something else than the target.
    My target is always an empty Gameobject so the player can shoot in a straight line and if it collides with an object of the game world it doesnt get noticed.
     
  18. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Bug with null hit should fix this replaced code (projecticleCollisionBehaviour.cs)

    RaycastHit raycastHit;
    if (Physics.Raycast (tRoot.position, direction, out raycastHit, distanceNextFrame + effectSettings.ColliderRadius, LayerMask)) {
    endPoint = raycastHit.point - direction * effectSettings.ColliderRadius;
    CollisionEnter ();
    }
    if (raycastHit.transform! = null)
    hit = raycastHit;

    At this

    if (Physics.Raycast (tRoot.position, direction, out raycastHit, distanceNextFrame + effectSettings.ColliderRadius, LayerMask)) {
    hit = raycastHit;
    endPoint = raycastHit.point - direction * effectSettings.ColliderRadius;
    CollisionEnter ();
    }
     
  19. rcober

    rcober

    Joined:
    Jan 26, 2013
    Posts:
    52
    Love the effects...

    Having troubles getting the lightning_strike to go on continuously?
     
  20. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    In the demo is not the constant use of lightning?
    IIf you want to effect a shot every 0.5 seconds, then create an instance of the effect of every 0.5 seconds.
     
    Last edited: Jul 22, 2014
  21. rcober

    rcober

    Joined:
    Jan 26, 2013
    Posts:
    52
    Kripto289 - I was trying to avoid spawning endless instances.

    Is it possible to just use one instance? I tried reenabling the GameObject on the EffectDeactivated event, but that doesn't work. There is some kind of timing issue with reenabling and the next collision callback.

    I will try to use 2 instances and ping pong.

    What would be really useful is a simple "line" that continuously flows electricity. You can move the endpoints and it just keeps flowing. Turn it off when needed.

    Thanks again for any other feedback
     
  22. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Lightning made by uv-animated texture. Now the animation looped and when animating the third frame, the event is triggered explosion particles.
    This is what you need :)
     

    Attached Files:

    Arkade likes this.
  23. rcober

    rcober

    Joined:
    Jan 26, 2013
    Posts:
    52
    Thanks Kripto289!!!

    Trying out now ....

    Should I just copy over on top of the existing?
     
  24. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Scripts can be replaced. If you need the old lightning effect, it is better to make a copy.
     
  25. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    The effects look great, thanks for this pack!

    The shields are giving me a bit of trouble. How can I make it so the effects are visible from both inside and outside the shield? The prototype I am working on is a first person game, and if the player is surrounded by a shield (such as a water shield), I'd like for the player to see the distortion from within. Right now you can't even tell a shield is surrounding you.

    Also, would it be possible to cut the shields in half so that they only protect the front of the character? I will have to create a dome like collider for this, but other than that, how would one go about producing this?

    Thanks for any help!
     
  26. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    Okay, you can ignore those questions. I see now that it is just a matter of changing out the mesh to get the half shield, and I'm guessing if I just make a double sided sphere with the normals pointing in on the inner sphere, I should get the other effect I was looking for. Or is there another way to go about it?

    Thanks!
     
  27. SureSight

    SureSight

    Joined:
    Aug 2, 2013
    Posts:
    65
    I love the shield effects, but I have a question about shapes.

    I'm creating a third person shooter and I am trying to achieve a personal shield effect that follows the basic shape of the character (not a sphere).
    This would look similar to the shields used in Mass Effect 3 (see attached)
    Miranda_at_sanctuary.png

    How might I approach this?
    Any help is welcome
     
  28. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    All shields can be added as a a 2nd material. But the shields using a shader "particles / additive" should be replaced by "effects / GlowAdditiveSimple", otherwise the shield will not be displayed.
    Effects of distortions overlap fine :)
     

    Attached Files:

    • 11.png
      11.png
      File size:
      433.8 KB
      Views:
      960
    SureSight likes this.
  29. matt1610

    matt1610

    Joined:
    Dec 8, 2013
    Posts:
    15
    I'm struggling to get the explosion particle systems to trigger for some reason, could someone give an explanation on how to get it right?

    Thanks!
     
  30. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    @matt1610, The explosions occur when the spell collides with something, so as long as the objects the spells are colliding with have a collider attached, it should work. If that's not the issue, have you changed anything about the prefabs? You can also make sure the Layer Mask is set to Everything on your Effect Settings component. Other than that, I'm not sure.

    @kripto289, what is the reason for the colliders on the spells? As far as I can tell, you are ray casting manually to figure out if spells collide with anything, so the colliders are not used. Is that correct?

    Also, I am trying to understand the code base, and I have some questions about some specific snippets. I have sent a private message with those snippets/questions, as I wasn't sure if you'd like me posting your code in a public forum. Thanks!
     
  31. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    If you want to independently control the explosion, it is enough to cause "effectSettings.OnCollisionHandler (new CollisionInfo ());"
    In other cases, when properly configured layerMask, projectiles and shields themselves must respond to the collision.

    Shields react to collisions with colliders of projectiles. If you do not use shields, you can remove colliders from projectiles.
    I found a more elegant solution, in a collision with an object, to verify that this shield, and make him the event of explosion. But this change, I plan in the next update.
     
    Last edited: Aug 4, 2014
  32. matt1610

    matt1610

    Joined:
    Dec 8, 2013
    Posts:
    15
    @gilley033 Thanks for the help! I think I have an idea whats going on. I am using my own script to move the object, like so:

    rigidbody.velocity = transform.right * ProjectTileSpeed;

    When I turn this off I think I see the particle effects when it collides with something, but I can't seem to figure out of to make the object move without using my own script. Is their some documentation for these particle effects that I just haven't found yet?

    Thanks!!
     
  33. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    @matt1610 The spell projectiles and shots immediately move towards the effectSettings.Target object on their own; you do not need to manually move them.

    You will need to make sure you position the root game object of the spell (the one the EffectSettings component is on) as well. As for what to use for the Target object, I am just using an empty GameObject that I position some distance in front of my camera every time I use a projectile spell.

    Here is some sample code I am using to fire a projectile:

    Code (CSharp):
    1. public override void OnBeginSpellCast()
    2. {
    3.      EffectSettings settings = ((GameObject)Instantiate(projectileSpell)).GetComponent<EffectSettings>();
    4.  
    5.      settings.transform.position = castOrigin.position;
    6.      settings.MoveDistance = maxDistance;
    7.      settings.MoveSpeed = speed;
    8.  
    9.      targetTransform.position = Camera.main.transform.position + ( 10f * Camera.main.transform.forward);
    10.      settings.Target = target;
    11. }
    12.  
    Where projectileSpell is one of the projectile or shot prefabs from the package, castOrigin is a transform I assign in the inspector, maxDistance and speed are inspector variables, and target is the empty game object I mentioned before. It's probably a good idea to use a pool, in which case instead of Instantiating the spell, you'd just do

    Code (CSharp):
    1. settings.gameObject.SetActive(true);
    when you're ready to fire off the spell.

    You can also add a delegate to the settings.EffectDeactivated event, which will enable you to add the spell back to your pool once it is deactivated.
     
  34. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    @kripto289 Okay, I see now. I think I will remove the colliders and just use SendMessage (or some other method) to let the shield know it was hit.

    Thanks!
     
  35. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    While there is no documentation, because I'm still just learning to write scripts, and maybe something will improve and edit in future updates.
    But later documentation will be required.
     
  36. matt1610

    matt1610

    Joined:
    Dec 8, 2013
    Posts:
    15
    @gilley033 Thanks man I'm using that script of yours and getting a lot closer to what I'm looking for.

    In which script are the collisions dealt with? I want to add a tag to these game objects so that they travel through one another if they collide with one another as I'm unable to fire them in quick succession, has anyone got this right?
     
  37. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    @matt1610 Create a new layer in the layer manager and call it "Spells" or something like that. Then, for the spells you don't want to collide with other spells, find the child object which contains the collider component. For example, I think all of the projectile spells contain a "Ball" game object which has the collider on it. Change the layer of that game object to the layer you created.

    Then you have to adjust the effect settings component of each spell so that they ignore this layer; I think the setting is called "Layer Mask." Uncheck the layer you created in the layer manager on each effect settings. You should be able to multi select the objects to uncheck the layer for a group of effect settings in one fell swoop. Just remember that a "check" means the spell will collide with that layer.

    Good luck!
     
  38. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    174
    I tried to attach the Honeycomb shield to one of my ships and for some reason when the ship moved it just left it behind.
    Here is a video of what I did:
     
  39. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    I am not positive, but it may have to do with the Rigidbody. Try removing it from the Shield child object and see if the behavior stops. It did for me.
     
    Snownebula likes this.
  40. Snownebula

    Snownebula

    Joined:
    Nov 29, 2013
    Posts:
    174
    OMG Dude! That worked! I didn't even think about that.
     
  41. RowdyMrB

    RowdyMrB

    Joined:
    Dec 8, 2012
    Posts:
    83
    Is Realistic Effects Pack 2 an add-on for 1 or are there major changes to the scripts as well?
     
  42. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    No, all the scripts are common to both packs.
     
  43. Kanshin

    Kanshin

    Joined:
    Aug 23, 2014
    Posts:
    5
    Hello Kripto289,

    Beautiful effects, great work!
    I am able to successfully implement Shot3 and some other shots in an FPS from a FirePoint (end of gun) to the target.
    When trying to use the same code with the BlueParticleShot it only seems to travel for a short distance and the explosion does not occur at point of collision as the other shots do.
    It appears you have a script (SetPositionOnHit) in the Explosion object of the BlueParticleShot prefab that contains an event override "effectSettings_CollisionEnter" that does not appear to be triggered so the explosion instead happens at 0,0,0
    I have tried different Instantiations for instance-
    Code (CSharp):
    1.                     EffectSettings settings = ((GameObject)Instantiate(BlueParticleShot)).GetComponent<EffectSettings>();
    2.                     settings.transform.position = startPos;
    3.                     target.transform.position = endPos;
    4.                     settings.Target = target;
    If I switch out the prefab in the above to use Shot3 it works great(with an explosion at target) but the BlueParticleShot does not appear to reach the target and the explosion happens at 0,0,0?

    Any suggestions?
     
  44. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    Fixed prefab.
     

    Attached Files:

  45. Kanshin

    Kanshin

    Joined:
    Aug 23, 2014
    Posts:
    5
    Thank you Kripto for the fast response!
    I downloaded and tried the prefab, it appears the Explosion object is removed from the prefab?
    I really like the explosions at the end of the shots, so am trying to get the BlueParticleShot to have the same explosion effect as the demo shows.
    The explosion on impact works for Shot3 but it appears that BlueParticleShot works differently than Shot3. Perhaps a different setting I am missing to get BlueParticleShot to have the explosion on impact?
    Any suggestions?

    Thank you Kripto!
     
  46. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    No, I did not remove the explosion. I just moved it in the hierarchy below.
    For the effects of the projectile, I move the entire prefab (or parent). Therefore, on impact, prefab will be located at the collision point. That is, the explosion will automatically move to that point.

    For the effects of using lineRenderer (laser, lightning, etc.), I calculate the collision point in the script "lineRendererBehavior". And in the script manually assign local position of impact. In this case, prefab does not move.

    I hope you understand me.
     

    Attached Files:

    • 11.png
      11.png
      File size:
      837.4 KB
      Views:
      887
  47. Kanshin

    Kanshin

    Joined:
    Aug 23, 2014
    Posts:
    5
    Thank you Kripto!

    I tried the new PreFab earlier this afternoon, but it was still behaving the same.

    I debugged it most of the afternoon. I now have it working the same as the other shots. With the Prefab that comes with the pack.

    What I did-

    In the SetPositionOnHit script (Under Explosion) I added 3 lines to the end of the Start method- And in the effectSettings_CollisionEnter method I changed the "var direction" to be "Vector3 direction" (c# preference :)) and commented out the
    "effectSettings.CollisionEnter += effectSettings_CollisionEnter;" in the Update Method.
    This allowed the explosion to happen when not reusing the Shot.
    Code (CSharp):
    1.   void Start()
    2.   {
    3.     GetEffectSettingsComponent(transform);
    4.     if (effectSettings==null)
    5.       Debug.Log("Prefab root or children have not script \"PrefabSettings\"");
    6.     tRoot = effectSettings.transform;
    7. Vector3 direction = (effectSettings.transform.position + Vector3.Normalize(effectSettings.Target.transform.position - effectSettings.transform.position) * (effectSettings.MoveDistance + 1)).normalized;
    8.  
    9.     transform.position = effectSettings.Target.transform.position - (direction * OffsetPosition);
    10.  
    11.     effectSettings.CollisionEnter += effectSettings_CollisionEnter;
    12.   }
    13.  
    14.   void effectSettings_CollisionEnter(object sender, CollisionInfo e)
    15.   {
    16.     Vector3 direction = (tRoot.position + Vector3.Normalize(e.Hit.point - tRoot.position) * (effectSettings.MoveDistance + 1)).normalized;
    17.     transform.position = e.Hit.point - direction*OffsetPosition;
    18.   }
    19.  
    Next to get the shot to travel the full distance to the target (was burning out within 10 meters) I decreased the Emission on the "ParticleExplosion" from 100 to 30 as it was hitting MaxParticles of 1000 too fast :)

    I also changed the way I am Instantiating the particle effect to correctly figure the distance-
    Code (CSharp):
    1.                     currentGo = Instantiate(blueParticleEffect, startPos, hitTransform.transform.rotation) as GameObject;
    2.                     effectSettings = currentGo.GetComponent<EffectSettings>();
    3.                     Vector3 v3 = endPos - startPos;
    4.                     float fDistance = v3.sqrMagnitude;
    5.                     effectSettings.MoveDistance = fDistance;
    6.                     target.transform.position = endPos;
    7.                     effectSettings.Target = target;
    8.                     currentGo.transform.parent = transform;
    9.  
    Thank you Kripto!
     
    Last edited: Aug 24, 2014
  48. x3Frozen

    x3Frozen

    Joined:
    Oct 22, 2013
    Posts:
    3
    Hi ,can you tell me more details about what programe you did used for UV animated textures?thx
     
  49. kripto289

    kripto289

    Joined:
    Feb 21, 2013
    Posts:
    505
    After effect, photoshop, particle illusion.
     
  50. hollysephiroth

    hollysephiroth

    Joined:
    Mar 25, 2014
    Posts:
    19
    Hello
    I really like those effects and plan on buying both packs , but I do have a question , In my game I use 2d elements like
    2d colliders 2d ray casts etc . How well will it work with your scripts ?

    Thanks