Tegleg Records

Tegleg Records
Tegleg Records

Thursday, 24 March 2011

Dynamicaly changing the Player Pawn

How to Dynamicaly change the Player Pawn.
Put this in your Player Controller. The example here is using an 'exec' function so it can be triggered from a button press or console command.


exec function FPress()
{
//declare the variables
local pawn p;
local vector l;
local rotator r; 

//set the variables 
p = Pawn;
l = Pawn.Location;
r = Pawn.Rotation; 

// get rid of the old pawn
UnPossess();
p.Destroy(); 

//spawn a new pawn and possess it
p = Spawn(class'SomePawnClass', , ,l,r);

//use false if you spawned a character and true for a vehicle
Possess(p, false);
}

UDK Easy Save System

How to save a variable in UDK unreal script.

class Something extends SomethingElse
config(SomeIni); //this points to an ini file where stuff is saved, in this case UDKSomeIni.ini

var config int SomeVar; // putting config allows you to save the variable

//your function where you set and save the variable
function SomeFunction()
{
SomeVar = 20; //give it a value

//SaveConfig() will save whatever variables have config
// it will create UDKSomeIni.ini (if it doesnt exist) and save the variable
SaveConfig();
}