Przejdź do głównej zawartości

Szukaj

How do I create Lightning Bolts that attracts to metal, and Sparks when it touches an Object?

  • FlashMedallion

    This could be pretty in-depth, and I'm pretty much going to make this up as I go. I'm going to assume your lighting is coming out of the sky, and for the sake of simplicity is one really long zag.

    I'd start by creating an object in the sky that uses a laserscope to find a target.

    Firstly you need your game to know what is Metal and what isn't. The simple way is to run around and slap a tag named 'Metal' on everything that you say is metal. A more robust way might be be to designate the surface type of all your metal things as Metal (that's a built-in option) and use your laser to report the surface type and figure that into your logic (I *think* that's possible but haven't checked for a while).

    Lets say you're using tags though. You want your laser (just one for now) to find a tag named Metal. Maybe it looks for the closest (i.e. the highest/tallest object) or maybe it's a random one.

    Then when it's lightning time (however you're deciding that) then you simply emit your lighting bolt at the location of the tag (with the bottom of the bolt at the tag). The bolt itself will have it's own timeline attached to it that activates when it's emitted - maybe it glows very bright for a split second, plays a sound, emits a new object (the Sparks you've made) then destroys itself.

Zaloguj się, aby dodać komentarz.