Legacy:DistanceSpriteDecoration

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search
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.
  1. Set up the new actor's properties:
  2. * 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.
  3. * Set the Texture property (in the Display group) to the sprite that should be displayed when the DistanceSpriteDecoration is viewed from afar.
  4. * 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'

<uscript> // ============================================================================ // DistanceSpriteDecoration // Copyright 2002 by Mychaeel <[email protected]> // 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;
 }

</uscript>

Related Topics