Sunday, June 18, 2017

xna - Lightning whip particle effects


I'm currently using Mercury Particle Engine for the particle effects in my game, and I'm trying to create a sort of lightning whip - basically a lightning effect bound to a line that curves when the player moves. I know how to use the editor, and I have particle effects working in game. However, I'm completely lost as to where I should start for this specific particle effect.


Perhaps if I could find the code for it in a different particle engine, I could convert it, but I can't seem to find that either. What I did find was a lot of tutorials for creating the lines associated with lightning programmatically, which doesn't help in this case because I don't want it to be rigid. Perhaps it would be more like some sort of laser beam with crackling effects around it? I'm running into a wall as far as even beginning to implement this goes.



Answer



Despite lightning consisting out of free electrons and ions I'm not sure if a particle effect is the way to go here. What you typically see is strands of electricity writhing about in a static (pun not intended) manner, it will be very hard to obtain this kind of visual effect by using a particle system alone:


A lightning whip (C) Warren Martineck


Furthermore, it is advisable to use a particle system solely for visual effect, because it's expensive to check individual particle collisions in a lot of cases and you're better off simulating the associated gameplay effects in another way.[1]



So, if you haven't done so already, you should create the gameplay effect for the whip first, by applying the techniques mentioned in the answer to 2D Rope Collision Detection, but instead of drawing a rope, use the curve based on the resulting positions as a custom emitter for spark-like particles.


This way you get a whip which behaves the way you want to (based on the physics parameters), efficient collision detection with enemy spaceships and your desired lightning particle effect.


Update: If you just want to achieve the effect in Super Stardust Delta (as shown in the image you linked, and throughout this movie), you could have the whip curve emit brightly lit (in the case of the game: reddish) particles which die relatively quickly, and make sure they start out smaller the further along the curve they are away from the space ship.


Alternatively, to add more realistic "squiggles", instead of drawing a rope texture, use a variation of the technique described in the lightning whip movie I linked earlier: http://www.youtube.com/watch?v=grQCOzrdlXs#t=173s



  1. Get an animated lightning texture, something like this: lightning texture, preferably animated

  2. And draw it multiple times along the curve, making use of blending, distracting particle effects like this and animation offsetting to cover up transition areas.


Alter-alternatively, draw a number of curves instead of just one, using slightly perturbed points and different weight parameters, to simulate the lightning strands (giving an effect comparable to the image above). Though the result on itself won't be as chaotic as lightning usually looks, you might still be able to come up with a nice effect by tweaking the emitter to more erratically dispense the lightning sparks.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...