| Home Page | Recent Changes | Preferences

CameraEffect

UT2003 :: Object >> CameraEffect

Base class for camera effects like screen overlays or motionblur.

How To Use

Only the first camera effect of a certain class actually works. However, any CameraEffect object can be added as often to a PlayerController's CameraEffects array as you want without breaking anything.

Your best bet when working with camera effects is to find an existing CameraEffect of the desired class in the local PlayerController's CameraEffects array and use that. If there isn't any, just fetch one from the ObjectPool.

This function will do exactly that:

//=============================================================================
// FindCameraEffect
//
// Looks for an existing CameraEffect object in the CameraEffects array first.
// Only if it doesn't find one, it takes one from the ObjectPool.
// That CameraEffect will be returned.
//=============================================================================

simulated function CameraEffect FindCameraEffect(class<CameraEffect> CameraEffectClass)
{
  local PlayerController PlayerControllerLocal;
  local CameraEffect CameraEffectFound;
  local int i;
  
  PlayerControllerLocal = Level.GetLocalPlayerController();
  if ( PlayerControllerLocal != None ) {
    for (i = 0; i < PlayerControllerLocal.CameraEffects.Length; i++)
      if ( PlayerControllerLocal.CameraEffects[i].Class == CameraEffectClass ) {
        CameraEffectFound = PlayerControllerLocal.CameraEffects[i];
        log("Found"@CameraEffectFound@"in CammeraEffects array");
        break;
      }
    if ( CameraEffectFound == None ) {
      CameraEffectFound = CameraEffect(Level.ObjectPool.AllocateObject(CameraEffectClass));
      log("Got"@CameraEffectFound@"from ObjectPool");
    }
    if ( CameraEffectFound != None )
      PlayerControllerLocal.AddCameraEffect(CameraEffectFound);
  }
  return CameraEffectFound;
}

The CameraEffect class will be added to the CameraEffects array, whether it is already there or not. This way you can simply remove one reference from the array if you don't need the CameraEffect anymore.

If no more references to the CameraEffect are left in the array you can free the CameraEffect object and put it back in the ObjectPool. The following function will do that automatically for you:

//=============================================================================
// RemoveCameraEffect
//
// Removes one reference to the CameraEffect from the CameraEffects array. If
// there are any more references to the same CameraEffect object, they remain
// there. The CameraEffect will be put back in the ObjectPool if no other
// references to it are left in the CameraEffects array.
//=============================================================================

simulated function RemoveCameraEffect(CameraEffect CameraEffect)
{
  local PlayerController PlayerControllerLocal;
  local int i;
  
  PlayerControllerLocal = Level.GetLocalPlayerController();
  if ( PlayerControllerLocal != None ) {
    PlayerControllerLocal.RemoveCameraEffect(CameraEffect);
    for (i = 0; i < PlayerControllerLocal.CameraEffects.Length; i++)
      if ( PlayerControllerLocal.CameraEffects[i] == CameraEffect ) {
        log(CameraEffect@"still in CameraEffects array");
        return;
      }
    log("Freeing"@CameraEffect);
    Level.ObjectPool.FreeObject(CameraEffect);
  }
}

These two functions are not part of the CameraEffect. You will have to implement them yourself.

Known Subclasses


Category Class (UT2003)

Category Class (UT2004)

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In