| Home Page | Recent Changes

DistanceSpriteDecoration

Actor >> Decoration >> DistanceSpriteDecoration

DistanceSpriteDecoration is a custom Decoration subclass that displays a (probably complex and performance-intensive) regular decoration mesh at close distances, but switches to displaying a simple sprite when viewed from afar.

http://mb.link-m.de/download/DM-DistanceSpriteDecoration.zip

Created by Mychaeel by request of LegalAssassin in this BuF thread.

Usage

  1. Add a DistanceSpriteDecoration actor where you want the decoration to appear. It'll be displayed as a skull sprite.
  2. Set up the new actor's properties:
    • Copy the Mesh, Skin and MultiSkins properties (in the Display group) from the regular decoration you want to have displayed when the player is close to the DistanceSpriteDecoration. If you need a solid decoration, also copy the values in the Collision group.
    • Set the Texture property (in the Display group) to the sprite that should be displayed when the DistanceSpriteDecoration is viewed from afar.
    • Set the DistanceSprite property (in the DistanceSpriteDecoration group) to the distance in world units where you want the decoration's display to switch from mesh to sprite display.

Implementation

See Embedding Code for how to get this code into your map.

After you have compiled the code, it is crucial that you set the following default properties (select Default Properties in the class's context menu in the actor browser) of your new DistanceSpriteDecoration class, or it won't work in network games:

Group Property Value
Advanced bNoDelete True
Advanced bStatic False
Networking RemoteRole ROLE_SimulatedProxy
Display Texture Texture'Engine.S_Corpse'
// ============================================================================
// DistanceSpriteDecoration
// Copyright 2002 by Mychaeel <mychaeel@beyondunreal.com>
// Free for use and modification.
//
// Decoration that is displayed as a mesh at close distances or a sprite when
// the local player is far away. Set the mesh in the Display/Mesh property, the
// sprite texture in Display/Texture.
// ============================================================================


class DistanceSpriteDecoration extends Decoration;


// ============================================================================
// Properties
// ============================================================================

var() float DistanceSprite;


// ============================================================================
// Variables
// ============================================================================

var PlayerPawn PlayerLocal;


// ============================================================================
// Tick
// ============================================================================

simulated event Tick(float TimeDelta) {

  if (PlayerLocal == None)
    foreach AllActors(class 'PlayerPawn', PlayerLocal)
      if (Viewport(PlayerLocal.Player) != None)
        break;

  if (PlayerLocal == None)
    return;

  if (VSize(Location - PlayerLocal.Location) < DistanceSprite)
    DrawType = DT_Mesh;
  else
    DrawType = DT_Sprite;
  }

Related Topics


Category Custom Class

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

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