Search Unity

Approach to doing a shield effect

Discussion in 'Editor & General Support' started by hsparra, Oct 13, 2005.

  1. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    What would be the best approach to creating the effect of a shield around a ship, where the shield mirrored the shape of the ship? I want to create an effect where the ship is hit to have the shield light up. My first goal is to do an effect that follows the contour of the ship. Later I want to have only part of the shield light up, then after that have an affect that gives the illusion of an impact on the shield.

    Would I do this in some modeling program as an animation? Or use a bunch of overlapping spheres and cubes in Unity? Write a shader? User the ability in the Pro version to use direct OpenGL commands? Some other way?
     
  2. Samantha

    Samantha

    Joined:
    Aug 31, 2005
    Posts:
    609
    I actually want to achieve something similar. I want to put a spherical shield around a ship, that is usually invisible, unless the ship is hit by a bullet. When that happens, I want to make the shield light up. If the shield is going to be somewhat transparent, you'll probably have to write a custom shader for it.

    One way I thought about doing this was to make a shield prefab, and each time the ship gets hit, instantiate the prefab. That covers the shield becoming visible. What's more difficult is creating some kind of impact effect. I'm still a bit puzzled as to how to achieve this, and the only thing I've figured out so far is that moving a point light around the shield in a certain way (I still have to play with this) should simulate some kind of energizing effect. What I don't know how to do is make the light affect ONLY the shield, and not the ship or the world.

    Hopefully that makes the shield concept a bit easier to swallow.
     
  3. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    If you are doing a spherical shield, you can probably put a sphere around your ship, then via script change the color and alpha where there is a collision. I believe the Space Dock widget from the widget contest did this.
     
  4. guategeek_legacy

    guategeek_legacy

    Joined:
    Jun 22, 2005
    Posts:
    659
    would you not be able to create an animated texture that has the energy radiating out and then dictating that is somehow called and played through once on the shield object when its shot at. Though it might be very difficult to have it so it radiates out from the point of contact.

    In FPS's when you shoot a bullet at a wall it leaves some sort of stamp where the bullet hit to make it look like a hole. If you could somehow do this but have an animated texture that plays through once it might work.

    As you can tell I haven't got a hang of unity yet :p but maybe this will be food for thought. Jeff
     
  5. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Using and animated texture sounds like something worth looking into. Now all I have to do is figure out how to use those a modeling package.
     
  6. pikachu

    pikachu

    Joined:
    Aug 6, 2005
    Posts:
    38
    Here is a proposed approach:

    1) Proper Impact Position
    Retrive the x,y,z position of the impact and translate to a relative position against the ship. This is to ensure that your impact appears on the ship while the ship is moving. Or else it might seem to be stuck in space while the ship is moving or rotating.

    2) The Impact Effect
    Position an invisible poly or disc and parent it to the ship. Then attach a particle emitter (http://otee.dk/Documentation/Manual/Particle Systems.html). 2 or 3 particle with additive mask are then emitted that grow and shrink very quickly while remaining in place. If you use a good texture (Something with a radial fill) you should get a nice effect. I suggest trying out the demo of Particle Illusion to quickly test some textures before importing them. That allows for a much more iterative approach to texturing. (This is the most difficult part, so make sure that you get yourself a nice tool.)

    3) Absorbing the shock
    If your ship is in space I would expect the ambient lightning to be in the darker area. Your ship will hopefully (for this trick) also a bit dark instead of bright pink.
    I suggest creating a semi-tranparent copy of the ship with a white tint that is extremly glossy. You should then be able using a spot light that increases the radius very quickly to achieve a nice flash effect. If it is fast enough it should look pretty good.
     
  7. hsparra

    hsparra

    Joined:
    Jul 12, 2005
    Posts:
    750
    Thank you for the pointers. I definitely have some learning to do.
     
  8. HashbangGames

    HashbangGames

    Joined:
    May 7, 2011
    Posts:
    40
    @Pikachu - Thanks for the awesome tips! This gave me the exact effect I was looking for. In combination with a "force field" shader script that I found I have created the perfect Absorbing Shock effect and It came out looking fantastic.

    Once I get my ducks in a row, I will export this as a prefab for anyone to use.

    Thanks everyone for their quality posting!
     
  9. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Quite possibly the oldest thread necro in Unity forum history.
     
  10. Xsnip3rX

    Xsnip3rX

    Joined:
    Aug 29, 2009
    Posts:
    197
    Did you get your ducks in a row yet? i wouldn't mind this prefab share.
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Archaeology.