There is no spoon

Legacy:Mapping Hello World

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Overview[edit]

This page is a basic scripting tutorial aimed at mappers who want to learn to create custom subclasses. It will explain how to make some sort of Trigger subclass that says "hello world" in the HUD message area by default.

Instructions[edit]

  1. Preliminaries:
    1. Subtract A Space
    2. Place A Playerstart
  2. Create A Subclass from Trigger, call it HelloWorldTrigger in package MyLevel.
  3. Cut the default code from the Script Editor and paste in this simple script:
//===============================================
// HelloWorldTrigger.
// Displays "Hello World!" to the player's HUD.
//===============================================
class HelloWorldTrigger extends Trigger
     placable;
 
function PostBeginPlay()
{
     Super.PostBeginPlay();
     Message = "Hello World!";
}
  1. Compile
  2. Add an Actor of this new class
  3. Set the following Properties: (not necessary with this HelloWorldTrigger code)
    1. Actor/Collision
    2. Something so it displays (light, texture, static mesh)
  4. Save and Playtest

Related Topics[edit]

Discussion[edit]

Unknown (author): some rough notes on what this page should have... please add / suggest / change

Musicalglass: Might want to point out that this quick method of subclassing will not work for all needs, such as working with animated skeletal meshes. List a few circumstances where you might need to compile the long way and link to that bit and maybe Playing Mesh Animations for a sample tutorial. I actually have a second tutorial which I didn't post dealing with the second part of Playing Mesh Animations using the simple mesh cube that comes with the editor. Most likely far too wordy for your tastes, but I'd be happy to submit it for your review. I wanted to take things like rotation and translational values and experiment with doing simple scripting exercises such as how to add Touch or a Trigger or script a sequence or call on different states. We need more practical examples of simple scripts and maybe tie it in with one of these simple tutorials so people can get their feet wet with coding with some kind of visual feedback suitable for a gaming environment.

SuperApe: This page seems to need a little more explanation, a little more concepts and elements-type stuff. I might suggest we use one of the Third-Party Components for the "Paste in a simple script" step. We could have a RandomTrigger activate three colored TriggerLights, for example. And, the page title kind of threw me off, should it be more like, "Scripting Hello World"?

Tarquin: Not really, the UnrealScript Hello World is a mutator. :)

SuperApe: Note any stock Trigger will do (the work of the code above) if you put, "Hello World" in the Trigger -> Message property. Maybe we should do something more custom.

Tarquin: But then there wouldn't be any scripting! The purpose of a 'Hello world' program is to be simple, so I don't think something more custom would be suitable.

StarWeaver: Personally, I wouldn't expect the *mapping* concept of Hello World to involve scripting, just the minimum amount of complexity to create a functioning level; e.g., perhaps, "Select a texture that won't make you yark, subtract a standard rectangular space, add a player start and one interactable object like a pickupbase."

Tarquin: That's Create a room. basically, what I was trying to do here was starting point for: 'Want some code in your map? Don't want to code a whole mutator just to get started?'

SuperApe: :) I see the point of using this page as a starting point for using custom scripts by mappers. I see UnrealScript Hello World is a more advanced scripting tutorial. (BTW, those should be linked as a series of "Basic Procedure"-like steps for Modding from Making Mods, IMHO) I think my earlier comment about how this particular code duplicated the functionality already available in Trigger was to be taken together with the suggestion that we use one of the simpler scripts from Third-Party Components. To me, to introduce scripting with the above code to perform that function would be confusing a) the issue of what a Trigger does by default and b) the issue of how one gets a custom actor to display or broadcast a message. Although you're right, it is simple, it doesn't actually hit the point of using custom code: to get extra functionality not available in stock objects. Also, note that this code doesn't require any other property settings, which as the steps above indicate, might be good to include in a tutorial like this. As far as the name of the page, as long as it's linked to well, it probably doesn't matter so much. But, on the other hand, I might suggest "Mappers Hello World", to keep the idea that this is a simpler version of scripting tutorial. That title sounds like, "Math for Artists", to me and seems more appropriate. What does everyone think of that?


Category:Legacy Mapping

Category:Legacy Tutorial

Category:Legacy To Do – This tutorial needs some work.