I love the smell of UnrealEd crashing in the morning. – tarquin

Legacy:RetriggerableBreakingGlass

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT :: Actor (UT) >> Effects (UT) >> ExplodingWall >> BreakingGlass >> RetriggerableBreakingGlass (custom)

This special version of the BreakingGlass actor spawns glass fragments every time it is triggered.

To use it, simply create a subclass of the BreakingGlass class, paste the code below, compile changed scripts and follow the Making Glass Break tutorial, except that you use this actor instead of the BreakingGlass class it derives from.

Related Topics[edit]

Source Code[edit]

//=============================================================================
// RetriggerableBreakingGlass by Wormbo.
// 
// Spawns stuff every time it's triggered.
//=============================================================================
class RetriggerableBreakingGlass extends BreakingGlass;
 
var int DefaultHealth;
 
auto state Exploding
{
  function BeginState()
  {
    Super.BeginState();
    DefaultHealth = Health;
  }
 
  function Explode( pawn EventInstigator, vector Momentum)
  {
    local int i;
    local Fragment s;
    local actor A;
 
    if( Event != '' )
      foreach AllActors( class 'Actor', A, Event )
        A.Trigger( Instigator, Instigator );
 
    Instigator = EventInstigator;
    if ( Instigator != None )
      MakeNoise(1.0);
 
    PlaySound(BreakingSound, SLOT_None,2.0);
 
    for (i=0 ; i<NumWallChunks ; i++) 
    {
      s = Spawn( class 'WallFragments',,,Location+ExplosionDimensions*VRand());
      if ( s != None )
      {
        s.CalcVelocity(vect(0,0,0),ExplosionSize);
        s.DrawScale = WallParticleSize;
        s.Skin = WallTexture;
      }
    }
    for (i=0 ; i<NumWoodChunks ; i++) 
    {
      s = Spawn( class 'WoodFragments',,,Location+ExplosionDimensions*VRand());
      if ( s != None )
      {
        s.CalcVelocity(vect(0,0,0),ExplosionSize);
        s.DrawScale = WoodParticleSize;
        s.Skin = WoodTexture;
      }
    }
    for (i=0 ; i<NumGlassChunks ; i++) 
    {
      s = Spawn( class 'GlassFragments', Owner,,Location+ExplosionDimensions*VRand());
      if ( s != None )
      {
        s.CalcVelocity(Momentum, ExplosionSize);
        s.DrawScale = GlassParticleSize;
        s.Skin = GlassTexture;
        s.bUnlit = bUnlitGlass;
        if (bTranslucentGlass) s.Style = STY_Translucent;
      }
    }
    Health = DefaultHealth;
  }
}