To create a custom sprite actor for use in UDK, you'll first need to import a texture to UDK, so we'll do this in two parts, one for setting up a texture, and one for attaching that texture to a custom actor script.

1.) Importing a Texture to UDK

To import a texture to UDK, you'll first need an image.  This image will have two very specific requirements:

1.) It must be in the windows .bmp file format.
2.) It must be a perfectly square image, with dimensions in powers of 2, like 1024 x 1024 or 512 x 512.

UDK will not allow you to even try to import a texture if it does not conform to these two criteria.

You can create your own image in image software like GIMP, or find something using Google (try the "Exactly..." filter in the size section on the left of Google Image search to refine your results to images that fit your size requirements).

Make sure your image has transparency.  If not, you'll have an awkward-looking square picture with a background.

Make sure the image is saved as a .bmp.  I did this for my custom sprites by opening the .jpgs in GIMP and clicking Export and saving them as .bmps.

In UDK, open your content browser and click "Import", then select your image and give it the appropriate package, grouping, and title.  Once you've completed this step, you should have a brand-new, usable texture in UDK.

Keep UDK open for a minute, and we'll get into the script.

2.) Creating a Sprite Actor in Script

In whatever script-editing software you use (I use Microsoft VisualStudio with NFringe; it plays nice with UDK), create a new script in your custom scripts package.

Here's what you'll need in the body of your script:

class MyCustomSprite extends Actor
   placeable;

defaultproperties
{
  begin Object Name=YourSprite
    Sprite= // Sprite's Full Name Goes here
    HiddenGame=false
    AlwaysLoadOnClient=False
    AlwaysLoadOnServer=False
  end Object
  Components.Add(YourSprite)
}


Go to UDK and find your texture in the content browser, right click on it and find the option "Copy Full Name to Clipboard" and insert it into the relevant space in the script, after "Sprite=".

That's it.

Save your scripts, close UDK and reopen it to rebuild your scripts, and you can find your sprite in the "Uncategorized" section of the Actor Classes tab in your Content Browser.

Your comment will be posted after it is approved.


Leave a Reply.