| Home Page | Recent Changes | Preferences


It's just a wooden barrel. You can shoot it and it shatters.


A respawning barrel.

Remaining problems:

  • no effect of any kind when the barrel reappears. You might want some sort of swishy wizz or something
  • you can be standing where the barrel really is when it reappears, and then you're sort of inside it

To use this script in your map: Create A Subclass.

// ReviveBarrel.
class ReviveBarrel extends Barrel;

var() float TimeToRespawn;
var int InitialHealth;

function PreBeginPlay()
  InitialHealth = Health;

function Vanish(bool bVanish)
  bHidden = bVanish;
  bBlockActors = !bVanish;
  bBlockPlayers = !bVanish;
  bProjTarget = !bVanish;

simulated function Frag(class<fragment> FragType, vector Momentum, float DSize, int NumFrags) 
  local int i;
  local actor A, Toucher;
  local Fragment s;

  if ( bOnlyTriggerable )
  if (Event!='')
    foreach AllActors( class 'Actor', A, Event )
      A.Trigger( Toucher, pawn(Toucher) );
  if ( Region.Zone.bDestructive )
  for (i=0 ; i<NumFrags ; i++) 
    s = Spawn( FragType, Owner);
    s.DrawScale = DSize*0.5+0.7*DSize*FRand();


state Absent 
  Health = InitialHealth; // restore health

  Sleep( TimeToRespawn );



Wormbo: You should toggle bHidden instead of changing the DrawType.

Tarquin: Thanks :) Had to sort out blocking as well. Mych will not like me calling that function Vanish() but I can't think of a better name :(

Wormbo: What about "SetVisibility" or "SetHidden"?

Tarquin: Great! Thanks :)

Foxpaw: It might not hurt to have both, sort of. It's a little bit of overhead at the interpreter level, but not that big of a deal. In my GUI classes I use a SetHidden function, then a Show and Hide function that are just one-line functions that call SetHidden( false ) and SetHidden( true ) respectively. Effectively it's the same, but I guess it kind of helps the readability. If you're into that sort of thing. :D

Tarquin: I was thinking this could make a tutorial about subclassing and states, but it's not very neat what with inheriting one state from Barrel and a load of code from Decoration. So I guess for SetHidden it's a case of what's clearest for people to read. Your idea of Show() just being a call to setHidden is neat, but I don't know how easy to grasp it would be.

Category Class (UT2003)

Category Custom Class

Category Tutorial

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands


Mapping Topics

Mapping Lessons

UnrealEd Interface


Scripting Topics

Scripting Lessons

Making Mods

Class Tree


Modeling Topics


Log In