Game Development Community

Make lightning always hit the same target (yes, I know in nature its never supposed to do that)

by Jeff Yaskus · in Torque Game Engine · 02/20/2010 (10:50 pm) · 4 replies

I'm adding an electrical storm to my mission map ... and have the lightning working, but I wanted it to start out up in the clouds (300z?) ... in a random radius around a tower I added ... but I wanted ALL the bolts to hit the tower.

I set it up as follow, but the lightning seems to originate in the area around the tower (ok) but go down to the ground instead of hitting the tower.

new Lightning(ElectricalStorm) {
         position = "-92 -217 300";
         rotation = "1 0 0 0";
         scale = "5 5 300";
         dataBlock = "LightningStorm";
         strikesPerMinute = "30";
         strikeWidth = "1.5";
         strikeRadius = "2.5";
         color = "1 1 1 1";
         fadeColor = "0.1 0.1 1 1";
         chanceToHitTarget = "100";
         boltStartRadius = "150";
         useFog = "1";
      };

I tried setting strikeRadius and strikeWidth ="1" but made no apparent difference -- bolts still contact the ground instead of the tower.

Do I need to somehow tell it the TOP (%Z) of the tower coordinates ? Any suggestions ??

Here is a screen shot (you might have to copy and paste the URL)

http://cid-5a085d65943aa005.skydrive.live.com/self.aspx/Orcs%20vs%20Humans%20Fa...

#1
02/21/2010 (3:49 am)
There is a function to have lightning strike a player somewhere..I cant tell you what it is off the top of my head but you could modify it and have it strike your tower, or you can make a subclass of lightningdata and have a definite strike point were all lightning strikes land
#2
02/22/2010 (8:40 pm)
I thought it must be a matter of the variables used to define the lightning - my copy of GPGtT said something like this;

strikeRadius = "2.5";
## sets the random size of the impact area .. ie. the area in which the bolts are to "end"

boltStartRadius = "150";
## sets the radius around position, in which lightning bolts will "start"

I'm trying to make a "lightning rod" effect in essence ... lightning kicking off constantly, always making contact with the top of a tower. (the one from the demo mission)

GPGtT also mentions a "textured" style of lightning is available -- but so far, I can't find any example resources to make it work ... such as the requires bitmap images

#3
02/23/2010 (11:08 am)
I tried playing with the variables to control the textures used and the start/end points of the bolts ... and my changes seemed to make very little difference.

Then I dug through the forums ... and found that it apparently doesn't use the textures properly.

(EDIT: was this ever fixed? found a post from 2002 -- but nothing newer. the c++ code wasnt clear to me -- looked like it only does procedural and not textures?)

BUT I did changed the strikeRadius and strikeWidth to 0.25 each ... and it looks much better, nice thin blue/white lightning strikes. And about 50% of the strikes hit the "position".
#4
02/24/2010 (9:43 am)
$randomPos = "";
randLightningPos();

function randLightningPos();
{
  %rand0 = randomNumFunction(someNum1,someNum2);//there is a function that will generate random numbers between a given range (someNum1 and someNum2)
  %rand1 = randomNumFunction(someNum1,someNum2);
  %rand2 = randomNumFunction(someNum1,someNum2);
  $randomPos = %rand0 @ " " @ %rand1 @ " " @ %rand2;
  schedule(someTime, 0, randLightningPos);
}

new Lightning(ElectricalStorm) {   
         position = $randomPos;   
         rotation = "1 0 0 0";   
         scale = "5 5 300";   
         dataBlock = "LightningStorm";   
         strikesPerMinute = "30";   
         strikeWidth = "1.5";   
         strikeRadius = "2.5";   
         color = "1 1 1 1";   
         fadeColor = "0.1 0.1 1 1";   
         chanceToHitTarget = "100";   
         boltStartRadius = "150";   
         useFog = "1";   
      };
psuedo-code speaking. This or some variation of this may work. Hope this helps!!!