Week 4 - FAQ

Place any questions / discussion here:

Q: I have been playing around with the "PlayerReplicationInfo.Score += 1;" line for a while now in order to get the score to appear as you collect the 'simplePickup'. However I can not get it to work. I tend to receive a log warning message saying "Accessed none".

A: The PlayerReplicationInfo.Score is drawn on the HUD already in the bottom corner, what I've done is edit the PRI.Score in the SimplePikup class then left the HUD class to deal with writting the score to the screen via the scoreBox in place
-Martin Allen

Hey, in my simple pickup class i have this function which adds to the score nicely.

simulated static function UpdateHUD(HUD H)
{
    H.PlayerOwner.PlayerReplicationInfo.Score+=1;
}

hope this helps. -Thomas Marsh

Hey, this works, but have you thought of simply using the actor which is passed as a parameter in the "Touch" event in the pick up class?
Your solution is fine, but it seems to me that passing the HUD as a parameter is a bit useless, considering it is not related in any away to the player's score or the actual pickup : it just provides you with a variable for the PlayerController, which you can get in the Touch event of the pickup class anyway.
In my opinion, doing it this way makes a lot more sense, and also, I supposed you had to call that method somewhere else, like in the HUD class, which is not necessarily very convenient when getting rid of glitches. Anyway, just my suggestion, see what you think about it.

-Craig Hupin

Unreal Script Editing

Upon watching the Unreal 3D Buzz tutorials, during there scripting VTM's i realised they are using a program called "Context":

Picture: http://www.jackson-carl.com/Images/context.png
Website: http://www.contexteditor.org/

This is a free program very similar to notepad ++ with built in settings for x86 assembly also! This program takes up unreal script’s looks and layout's so putting in // will actually go green and comment out a line, same with "class, default properties, extends" being made blue for example and other properties and variables. Context does not do this straight away, but requires a file as noted here: http://wiki.beyondunreal.com/Legacy:ConTEXT/UnrealScript, just take that code put it in context and save it as UnrealScript.chl and put Context highlighter directory:

Example: C:\Program Files (x86)\ConTEXT\Highlighters

This also gives you a "Save as" option for unreal script "Unrealscript (*.uc)

This may be usefull for some people : )

-Carl Jackson

Fixing None Animation/Fixing Jumping

This is down to John sneakily deleting the variable name of the jump animation.

Open up ExamplePawn.uc, scroll down to the bottom of the page to the default properties, look for this block;

TakeoffAnims[0]="JumpFTakeoff"
TakeoffAnims[1]="JumpFTakeoff"
TakeoffAnims[2]="JumpFTakeoff"
TakeoffAnims[3]="JumpFTakeoff"
TakeoffStillAnim=

Can you spot the problem?

Basically you need to assign something to TakeOffStillAnim, either "JumpFTakeoff" or "JumpTakeoff" both work.

There is still a slight problem, if you jump and then press Forward and either Right or Left at the same time it gives you another "None" error, I'll look into fixing it.

-Jimmy Greasley

After the initial fix, the error only occurs when the direction is held down too long before hand, maybe this can lead someone in the right direction? I have had a brief look, but I am unable to locate the source so far…

-Matt Davis

Removing the NVidia Logo

This is a very easy thing to implement. I'm unsure if it's possible to do using script, either way this works and involves changing one line in an INI file.

Open up the main INI file (MyMod.INI or Greasley_FF_Treasure in my case), look at the [URL] section, it's the first section when you load up. Look for this line;

LocalMap=NvidiaLogo.ut2

It's line 6 if your INI hasn't been played around with (much), change this to;

LocalMap=NoIntro.ut2

NoIntro is a standard map included in the game that contains only the required information to load the main menu, if you open it up in UnrealEd you'll understand what I mean, try opening up NvidiaLogo too, it's interesting how they've implemented the cutscene.

Anyway, make sure you save the file, you don't need to rebuild, and have fun.

-Jimmy Greasley

Using the GUI Editor on your MainMenu

By pressing Ctrl+Alt+D you can enter a design mode where you can edit the display of your main menu.

Tip: Press F1 to bring up all the commands that are available when you are in this mode, very useful.

-Matt Davis

Help! My SimplePickup isn't in the Actors Browser

It's okay, you might just be using the wrong editor. Don't forget there's an editor in your mod folder that uses your mod files. If you use that one, you should be able to find your SimplePickup class easy. :)

- Sean-Rafael

Just to add to this another way to get the SimplePickup to appear is to open the .U file named after your classes folder found in the System folder in unrealEd

- Martin Allen

In reply to the 2 posts above. You can load your custom Actor by navigating to your system folder, but if you try to edit your level at a later date UnrealEd will crash. In order to edit your level, you will need to load UnrealEd with the shortcut made in your mod folder.

- Kirk Brazil

Xbox 360 Controller

Incase there is anyone out there having issue's with this, such as the camera spinning i thought i would upload my current values in my moduser.ini

JoyX=Axis aBaseX SpeedBase=100.0 DeadZone=0.1 Invert=1
JoyY=Axis aBaseY SpeedBase=300.0 DeadZone=0.1 Invert=-1
JoyZ=
JoyR=Axis aBaseX SpeedBase=40 DeadZone=0.1
JoyU=Axis aLookUp SpeedBase=20 DeadZone=0.1 Invert=-1
JoySlider1=
JoySlider2=

This should allow you to move your character around with the left analog stick, and move the camera with the right analog stick.
-Carl Jackson

Here is a quick button reference for the Xbox 360 controller:

Joy 1 -> A
Joy 2 -> B
Joy 3 -> X
Joy 4 -> Y
Joy 5 -> LB
Joy 6 -> RB
Joy 7 -> Back
Joy 8 -> Start
Joy 9 -> Left Thumbstick Pushed down
Joy 10 -> Right Thumbstick Pushed down
Joy 11 -> N/A or not yet found
Joy 12 -> N/A or not yet found
Joy 13 -> Dpad Up
Joy 14 -> Dpad Right
Joy 15 -> Dpad Down
Joy 16 -> Dpad Left

Joy X -> Left Thumbstick x-axis
Joy Y -> Left Thumbstick y-axis
Joy R -> Right Thumbstick x-axis
Joy U -> Right Thumbstick y-axis

Joy Z -> Both triggers.

In my testing I found Joy V really messes with the camera and character.
- Matt Keyte

The camera still moving up/down after letting go of the analog stick is just where its too sensitive! I actually use:

JoyU=Axis aLookUp SpeedBase=20 DeadZone 0.01 Invert=-1

- Philip Morby

If you can not collect pickup items in your mod just put the variable bCanPickupInventory=true in the ExamplePawn class.
- Lukasz Pasek

Q. I wondered if anyone had come close to getting text to appear on screen when their pickup is touched by the player?. So far I've managed to get text on the screen using Canvas in the HUD class. I've had a look in the class files and the variable that needs to be displayed is "PickupMessage". At the moment I'm looking into the use of a boolean/timer solution unless I can find something in the code files.

-Robert Smith

**Draw Messages **

A. You can put a "Pawn(Other).ClientMessage(PickupMessage);" in your Touch function. Right know I can not figure out something better than this way to do it.
[SMALL UPDATE]
Paste it to your example Pawn class :

function HandlePickup(Pickup pick)
{
    PlayerController(Controller).ClientMessage(pick.PickupMessage);
}

or
function HandlePickup(Pickup pick)
{
    ClientMessage(pick.PickupMessage,);
}

instead of "Pawn(Other).ClientMessage(PickupMessage);" mentioned before. In both cases it displays the pickup message.
-Lukasz Pasek

Draw Messages : alternate solution

I am not sure of the way John expected us to go for, when he said simple, but this is what I did.

I initially went with the ClientMessage, but I noticed a couple of weeks ago that it causes a memory leak (you can easily test it). It is not too serious, but after a couple of minutes, provided your computer is not very fast, it will start to lag, so be careful…

Instead, I went for another solution which is quite close to the behaviour in the tutorial : I simply got my Hud class to inherit from HudBase, rather than the normal Hud, and then make use of the the "Super.DrawHud(Canvas canvas)" in the Hud's draw function.
If you have a look in this function, it is the "DisplayLocalMessages" function we are interested in.
In fact, if you have a look at the HudBase class, you will notice it also contains a structure for holding "HudLocalizedMessages" which also contains a "LocalMessage" (you will see the link later on).
Now, if you go back into the pickup class, go from the "AnnouncePickup" function, and walk your way up to the PlayerController class, you should see this :

function HandlePickup(Pickup pick)
{
    ReceiveLocalizedMessage(pick.MessageClass,,,,pick.class);
}

This pick.MessageClass is a "PickupMessagePlus" which inherits from "LocalMessage" (you can sort of see the pattern). If you then go into the LocalMessage class, there is a function called "GetString", which retrieves the string of an object, via the call of the object's "GetLocalString" function. Finally, if you go back into the Pickup class, you should be happy to see :

static function string GetLocalString(
    optional int Switch,
    optional PlayerReplicationInfo RelatedPRI_1,
    optional PlayerReplicationInfo RelatedPRI_2
    )
{
    return Default.PickupMessage;
}

Which is brilliant, because "PickupMessage" is exactly what we want to display.

Now this might not be the best way of making it work, and I might be wrong on some points, but hopefully, this should give you pointers on how the system works. If you have a better idea on how to implement the pickup display, feel free to post it, and/or correct my mistakes.

-Craig Hupin

Stopping the Timer::(accessing variables!!)

I know a few people were having problems with this i hope this helps.
My bool and float variable are declared in my ModController class:

var bool AllCollected;
var float  TimeTaken;

Take note this class extends Player controller which extends Controller.
I decided my pickup class was the best place to set these variables, due to it being where the score is incremented. If you follow up the Pickup class you will find it extends from Pawn, this is why you can do the following:

local Pawn P;
    if ( ValidTouch(Other) )
        {
            P = Pawn(Other);
        P.PlayerReplicationInfo.Score += PickupAmount;

This allows you to access variables and methods from the Pawn class (e.g P.PlayerReplicationInfo). We need to access the ModController class that eventually extends Controller. The Pawn class does not extend the Controller class, but if you inspect the pawn class it gives you a way to reference the Controller class by use of this variable:

var Controller Controller;

Therefore we can say:

local Pawn P;
local Controller C;
if ( ValidTouch(Other) )
        {
            P = Pawn(Other);
            C = P.Controller;

Now by using C. we have reference to variables and methods in Controller, my variables are inside ModController so we need a further step to be able to access those:

local Pawn P;
local Controller C;
local ModController MC;
if ( ValidTouch(Other) )
       {
            P = Pawn(Other);
            C = P.Controller;
            MC = ModController(C);

=) we can access variables inside our ModController class:

         if(P.PlayerReplicationInfo.Score == 10)
         {
            MC.AllCollected = true;
            MC.TimeTaken = Level.TimeSeconds;
        }

Finally to then check for these in our ModHud class it is much simpler because we can directly reference the ModController class:

local ModController MC;
MC = ModController(Owner);
if(MC.AllCollected)
{
//do something
}

I hope that explanation helped some of you. If you think you can improve it please feel free to edit.
-Luke Bass

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License