<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4505876340997549930</id><updated>2026-07-23T14:12:52.604-03:00</updated><category term="UnrealScript"/><category term="beginners"/><category term="udk"/><category term="Tutorial"/><category term="dynamic arrays"/><category term="foreach"/><category term="Actor"/><category term="Actor Reference"/><category term="Object Reference"/><category term="UTDroppedShieldBelt"/><category term="UTWeaponPickupFactory"/><category term="UnrealScript Object"/><category term="cast"/><category term="delegate"/><category term="iterator"/><category term="object tag"/><category term="out"/><category term="sort"/><category term="ternary operator"/><category term="unrealscript rand"/><title type='text'>Romero UnrealScript</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://romerounrealscript.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>44</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-3642615602220574611</id><published>2013-07-01T14:32:00.001-03:00</published><updated>2013-07-01T16:18:58.258-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginners"/><category scheme="http://www.blogger.com/atom/ns#" term="delegate"/><category scheme="http://www.blogger.com/atom/ns#" term="dynamic arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="sort"/><category scheme="http://www.blogger.com/atom/ns#" term="ternary operator"/><category scheme="http://www.blogger.com/atom/ns#" term="udk"/><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Using Delegates in UnrealScript</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
A delegate in UnrealScript is a type of variable that references a function. With the use of delegate is possible to set the function that should be called during the execution of the game.&lt;br /&gt;
&lt;br /&gt;
Before we create a new delegate we will first use one that is already defined in Unreal Engine 3.&lt;br /&gt;
&lt;br /&gt;
A &lt;a href=&quot;http://romerounrealscript.blogspot.com/2013/05/using-dynamic-arrays-in-unrealscript.html&quot;&gt;Dynamic Array&lt;/a&gt; has a function to sort its data. This function takes as a parameter another function that will be stored internally in a delegate. The description of this function in the &lt;a href=&quot;http://udn.epicgames.com/Three/UnrealScriptReference.html&quot;&gt;UnrealScript Language Reference&lt;/a&gt; is as follows:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;i&gt;&quot;Sort(SortDelegate): uses SortDelegate to sort the contents of the array in-place. SortDelegate should have signature matching the following:&lt;br /&gt;&lt;br /&gt;delegate int ExampleSort(ArrayType A, ArrayType B) { return A &amp;lt; B ? -1 : 0; }&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;i&gt;// a negative return value indicates the items should be swapped&quot;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
This description tells us to create a function that takes two parameters of the same type that is used in the Dynamic Array. We need to compare the two parameters and return a negative value if the items need to change position.&lt;br /&gt;
&lt;br /&gt;
The function is using the ternary operator &quot;&lt;b&gt;? :&lt;/b&gt;&quot; which is a type of &quot;if&quot; command abbreviated. The expression &lt;i&gt;&quot;A &amp;lt; B ? -1 : 0&quot;&lt;/i&gt; means that the comparison before the &quot;?&quot; will be evaluated. If the result is true, then the resulting value will be the first, which in this example is &quot;-1&quot;. If false, the resulting value will be the second, which is &quot;0&quot;. It is important to note that in this example the list will be in descending order. That is, the highest values ​​will be first in the list.&lt;br /&gt;
&lt;br /&gt;
The function that is created does not need to have the word &quot;delegate&quot; in its definition.&lt;br /&gt;
&lt;br /&gt;
Now imagine that we have in our game a Dynamic Array of Pawns as below:&lt;i&gt; &lt;/i&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;var array &amp;lt;Pawn&amp;gt; pawnList;
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;We want this list to be sorted by the Pawn&#39;s &lt;i&gt;Health&lt;/i&gt; attribute. The Pawns with more health must be at the beginning of the list.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Example function to sort the Pawns.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function int SortPawn(Pawn A, Pawn B)
{
    local int result;
          
    if(A.Health &amp;lt; B.Health)
    {
        result = -1;
    } 
    else 
    {
        result = 0;
    }
    
    return result;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The same function can be written in another way:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function int SortPawn(Pawn A, Pawn B)
{
    return (A.Health &amp;lt; B.Health) ? -1 : 0;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To sort you must call the Sort() function of the Dynamic Array:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;pawnList.Sort( SortPawn );
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
Now let&#39;s learn how to create a new delegate. To define a delegate in a class do so:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;delegate delegateName( parameters ... );
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To define a function that takes a delegate as a parameter:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function functionName( delegate&amp;lt; delegateName &amp;gt; delegateParameter)
{
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
In the example below it was created a delegate that will be called when a player (UTPawn) is dying. This delegate can be used to notify some other class in the game that need to perform an action when this happens.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class UTPawnDelegate extends UTPawn;

delegate notifyDeath( Pawn player ) ;

function SetDelegate( delegate&amp;lt; notifyDeath &amp;gt; newDelegate)
{
    notifyDeath = newDelegate ;
}

simulated function PlayDying(class&amp;lt;DamageType&amp;gt; DamageType, vector HitLoc)
{
    Super.PlayDying( DamageType, HitLoc );
    
    notifyDeath( self );
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/3642615602220574611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/3642615602220574611'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2013/07/using-delegates-in-unrealscript.html' title='Using Delegates in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-3882546556733861291</id><published>2013-05-22T15:33:00.000-03:00</published><updated>2013-05-22T15:33:28.003-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginners"/><category scheme="http://www.blogger.com/atom/ns#" term="dynamic arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="foreach"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="udk"/><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><category scheme="http://www.blogger.com/atom/ns#" term="unrealscript rand"/><category scheme="http://www.blogger.com/atom/ns#" term="UTDroppedShieldBelt"/><title type='text'>Using Dynamic Arrays in UnrealScript</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Dynamic Array is a collection of data items that can be resized during the execution of the game.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A Dynamic Array is a variable type declared as follows:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;var array &amp;lt; &lt;i&gt;arrayType&lt;/i&gt; &amp;gt; &lt;i&gt;arrayName&amp;nbsp;&lt;/i&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The array type can be primitives such as &lt;i&gt;int&lt;/i&gt; and &lt;i&gt;float&lt;/i&gt; or any class such as &lt;i&gt;Actor&lt;/i&gt; and &lt;i&gt;Pawn&lt;/i&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A Dynamic Array can also be defined as local variable within a function using the keyword &quot;local&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The current size of a Dynamic Array can be found in their &lt;b&gt;Length&lt;/b&gt;&amp;nbsp;attribute. Access to the individual elements of a Dynamic Array can be done with an index in the same way as in a static array. Remember that the index of an array always starts from 0.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;A simple example using Dynamic Array:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class EnemyTypes extends Actor;

var array &amp;lt;int&amp;gt; enemyTypeList;


function int getEnemyType(int index)
{
    if(index &amp;lt; 0 || index &amp;gt;= enemyTypeList.Length) 
    {
        return -1;  // Error: Invalid Index
    } 
    else 
    {
        return enemyTypeList[ index ];
    }
}

function setEnemyType(int index, int enemyType)
{
    if(index &amp;gt;= 0 &amp;amp;&amp;amp; enemyType &amp;gt;= 0)
    {
        enemyTypeList[ index ] = enemyType;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Note that in the above example, in the function &lt;i&gt;setEnemyType()&lt;/i&gt;, there is no problem if the &lt;i&gt;index&lt;/i&gt; is greater than the current size of the array, because a Dynamic Array will increase its size to store the required &lt;i&gt;index&lt;/i&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;There are some functions that are part of a Dynamic Array. Below are the main ones:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;AddItem&lt;/b&gt;( Element ): Adds an Element to the end of the Dynamic Array. The Element must be the same type of the Dynamic Array.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;RemoveItem&lt;/b&gt;( Element ): Removes an Element of the Dynamic Array.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;InsertItem&lt;/b&gt;( int Index, Element): Inserts an Element in the Dynamic Array at the specified index.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Find&lt;/b&gt;( Element ): Search for the Element within the Dynamic Array and returns the index of the found element, or &quot;-1&quot; if not found.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I did an example that creates a random amount of Shield Belts (&lt;i&gt;class UTGameContent.UTDroppedShieldBelt&lt;/i&gt;) in random positions. The Shield Belts instances that were created are added to a Dynamic Array. After creating all Shield Belts, the Dynamic Array is iterated using the &lt;a href=&quot;http://romerounrealscript.blogspot.com/2013/04/iterating-with-foreach-in-unrealscript.html&quot;&gt;ForEach&lt;/a&gt; operator to register in the Log the position of each Shield Belt created.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Code and image of this example:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class TestDynamicArrays extends UTGame;

var array &amp;lt;UTDroppedShieldBelt&amp;gt; shieldList;

function StartMatch()
{
    local UTDroppedShieldBelt shieldInstance;    
    local vector shieldLocation;
    local int totalShields;    
    
    super.StartMatch();

    totalShields = 10 + Rand(10);     
    
    do
    {
        //Choose a random position
        shieldLocation.X = -1000 + Rand(2001); //-1000 to 1000;
        shieldLocation.Y = -1000 + Rand(2001); //-1000 to 1000;
        shieldLocation.Z = 50 ;
    
        shieldInstance = spawn(class &#39;UTGameContent.UTDroppedShieldBelt&#39;, , ,shieldLocation);
        
        shieldList.addItem( shieldInstance );        
                
    } until ( shieldList.Length == totalShields ) ;
    
    `Log(&quot;TOTAL OF SHIELDS =&quot; @ shieldList.Length);
    
    //write in the log the position of all shields
    foreach shieldList( shieldInstance )
    {
      `Log( &quot;Location =&quot; @ shieldInstance.Location );
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZuP4Bkx1V77Oet0t1aVEZo-KoKvWDdPtqsXNMfnkHnxcf9Q2LVnrk4p9URbVJOxcuihMzomI7RB0hh13bM7tA0qof-UljffbzEN621Q_icA7UbscjYkzjzE5iImFnWXU4X3Mlm_GMCsck/s1600/unrealscript_03.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZuP4Bkx1V77Oet0t1aVEZo-KoKvWDdPtqsXNMfnkHnxcf9Q2LVnrk4p9URbVJOxcuihMzomI7RB0hh13bM7tA0qof-UljffbzEN621Q_icA7UbscjYkzjzE5iImFnWXU4X3Mlm_GMCsck/s400/unrealscript_03.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This log shows what was registered in one of the executions of the example.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;[0294.02] ScriptLog: TOTAL OF SHIELDS = 18
[0294.02] ScriptLog: Location = -390.00,183.00,50.00
[0294.02] ScriptLog: Location = -946.00,-300.00,50.00
[0294.02] ScriptLog: Location = -101.00,133.00,50.00
[0294.02] ScriptLog: Location = 225.00,701.00,50.00
[0294.02] ScriptLog: Location = 611.00,-908.00,50.00
[0294.02] ScriptLog: Location = -650.00,-532.00,50.00
[0294.02] ScriptLog: Location = -550.00,449.00,50.00
[0294.02] ScriptLog: Location = -245.00,531.00,50.00
[0294.02] ScriptLog: Location = 307.00,-890.00,50.00
[0294.02] ScriptLog: Location = -14.00,-534.00,50.00
[0294.02] ScriptLog: Location = -191.00,101.00,50.00
[0294.02] ScriptLog: Location = -756.00,832.00,50.00
[0294.02] ScriptLog: Location = 796.00,390.00,50.00
[0294.02] ScriptLog: Location = -833.00,-915.00,50.00
[0294.02] ScriptLog: Location = 780.00,-248.00,50.00
[0294.02] ScriptLog: Location = 492.00,841.00,50.00
[0294.02] ScriptLog: Location = 461.00,-526.00,50.00
[0294.02] ScriptLog: Location = 179.00,-266.00,50.00&lt;/code&gt;&lt;/pre&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/3882546556733861291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/3882546556733861291'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2013/05/using-dynamic-arrays-in-unrealscript.html' title='Using Dynamic Arrays in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZuP4Bkx1V77Oet0t1aVEZo-KoKvWDdPtqsXNMfnkHnxcf9Q2LVnrk4p9URbVJOxcuihMzomI7RB0hh13bM7tA0qof-UljffbzEN621Q_icA7UbscjYkzjzE5iImFnWXU4X3Mlm_GMCsck/s72-c/unrealscript_03.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-4431914840325602971</id><published>2013-04-15T14:49:00.001-03:00</published><updated>2013-04-24T07:47:53.603-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="beginners"/><category scheme="http://www.blogger.com/atom/ns#" term="foreach"/><category scheme="http://www.blogger.com/atom/ns#" term="iterator"/><category scheme="http://www.blogger.com/atom/ns#" term="object tag"/><category scheme="http://www.blogger.com/atom/ns#" term="Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="udk"/><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><category scheme="http://www.blogger.com/atom/ns#" term="UTWeaponPickupFactory"/><title type='text'>Iterating with ForEach in UnrealScript</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Before talk about iteration let&#39;s imagine an example. Say you built a game that in the levels there are several UTWeaponPickupFactory actors, but only one of them will have a special behavior that will be programmed in UnrealScript.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The UTWeaponPickupFactory class is found in this class hierarchy:&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFzAETBi27XduhAqJ-EXGvrGOdbH0Fb7sAkY-QT6gQrGk4wk7NrtkV8WqVNuQWIs04-ceApAI4TcMfDGd-v_X8tATLJUTm2wpeKHMK8x7nJhR8_5jbIJd87HISz8JH8mc7ydhKtphdD6Fj/s1600/unrealscript_02a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFzAETBi27XduhAqJ-EXGvrGOdbH0Fb7sAkY-QT6gQrGk4wk7NrtkV8WqVNuQWIs04-ceApAI4TcMfDGd-v_X8tATLJUTm2wpeKHMK8x7nJhR8_5jbIJd87HISz8JH8mc7ydhKtphdD6Fj/s1600/unrealscript_02a.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
For this example I will place in the level several UTWeaponPickupFactory actors as shown in the image below.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5r8rVuwb3eTEzpxYFf9yrdY7wvJ_1-jj3btze-Xj2InPVUSqRTtMUcvTOmqTn_VWp4fhOAYkyU9Gv3X2vUFPIsJoFsTH3sMqYinQvxkghmImJBHIokWdqUyCge35Ge6HXLDvoTHEweNc8/s1600/unrealscript_02b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;259&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5r8rVuwb3eTEzpxYFf9yrdY7wvJ_1-jj3btze-Xj2InPVUSqRTtMUcvTOmqTn_VWp4fhOAYkyU9Gv3X2vUFPIsJoFsTH3sMqYinQvxkghmImJBHIokWdqUyCge35Ge6HXLDvoTHEweNc8/s400/unrealscript_02b.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
I selected one of the UTWeaponPickupFactory actors, opened the &lt;i&gt;Properties Window&lt;/i&gt; (F4 key) and set the &quot;&lt;b&gt;Tag&lt;/b&gt;&quot; property with the value SPECIAL_FACTORY. This Tag property is in the Object category as seen in this image.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv_nDhU3KnHLaUbIaF5h9R8u8anwHSZkv7tCJLFBRhnE8jdSKrJOyrz9cdjusURq4XHUakal3O_CD4it-8VvsDmZaeKr8-aaxV67J1JVn99_ScHaR0LsjQeP4y_q_oDNhNwrjbG2uQX6U5/s1600/unrealscript_02c.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv_nDhU3KnHLaUbIaF5h9R8u8anwHSZkv7tCJLFBRhnE8jdSKrJOyrz9cdjusURq4XHUakal3O_CD4it-8VvsDmZaeKr8-aaxV67J1JVn99_ScHaR0LsjQeP4y_q_oDNhNwrjbG2uQX6U5/s1600/unrealscript_02c.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJPMHxsrL3b8Ad5ec5wHs1lCG4-HVY8Lz4raASB2BY2kAkmtiHwuw9dDu7KEgg_BW4r4gfmf3-9Z_QF_iLUBr-oSlnmLVYGTEpR-58wgwMqHn_QQPxoFrfn0ixwddHpXErNEQ6jLgnFWDr/s1600/unrealscript_02c.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;When starting the game we need to iterate through all the UTWeaponPickupFactory actors until find the one that has the value SPECIAL_FACTORY in the &quot;&lt;b&gt;Tag&lt;/b&gt;&quot; property. When find it we will store the &lt;a href=&quot;http://romerounrealscript.blogspot.com/2013/04/object-and-actor-references-in.html&quot;&gt;object reference&lt;/a&gt; of the current UTWeaponPickupFactory actor to be able to handle it in UnrealScript.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;That&#39;s what this code does.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class TestIteration extends UTGame;

var UTWeaponPickupFactory SpecialFactory;

function StartMatch()
{
    local UTWeaponPickupFactory factory;
   
    Super.StartMatch();
   
    foreach DynamicActors( class&#39;UTWeaponPickupFactory&#39;, factory )
    {
       
      if( factory.tag == &#39;SPECIAL_FACTORY&#39; ) 
      {
        SpecialFactory = factory;
        break;     // Ends the search
      }
    }
    
    Broadcast( self, &quot; Object Name =&quot; @ SpecialFactory.name) ;    
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
To test this code in UDK set the Game Type to &quot;TestIteration&quot;. (UDK Menu: &lt;i&gt;View -&amp;gt; WorldProperties -&amp;gt; Game Type&lt;/i&gt;)&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The &quot;&lt;b&gt;foreach&lt;/b&gt;&quot; command works with one type of function known as &lt;b&gt;Iterator&lt;/b&gt;. These functions have two parameters, the first parameter specifies the type of actor that it should search and the second is a variable that will receive the reference of the current actor in each iteration.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;i&gt;DynamicActors()&lt;/i&gt; is the most used iterator function. It searches in the Actors that are not &lt;i&gt;StaticMeshActor&lt;/i&gt;. There are several other iterator functions. The main iterators are declared together in the Actor class, just search for &quot;iterator&quot; in the file Actor.uc.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;There are other important iterators declared in the WorldInfo class (&lt;i&gt;Actor-&amp;gt;Info-&amp;gt;ZoneInfo-&amp;gt;WorldInfo&lt;/i&gt;). To use them you need to put a variable of the type &quot;WorldInfo&quot; in front of the iterator function name. All Actors have a &quot;WorldInfo&quot; variable. Code Sample:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from GameInfo.uc (Actor-&amp;gt;Info-&amp;gt;GameInfo)

function StartBots()
{
    local Controller P;

    foreach WorldInfo.AllControllers(class&#39;Controller&#39;, P)
    {
        if (P.bIsPlayer &amp;amp;&amp;amp; !P.IsA(&#39;PlayerController&#39;))
        {
            if (WorldInfo.NetMode == NM_Standalone)
            {
                RestartPlayer(P);
            }
            else
            {
                P.GotoState(&#39;Dead&#39;,&#39;MPStart&#39;);
            }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/4431914840325602971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/4431914840325602971'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2013/04/iterating-with-foreach-in-unrealscript.html' title='Iterating with ForEach in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFzAETBi27XduhAqJ-EXGvrGOdbH0Fb7sAkY-QT6gQrGk4wk7NrtkV8WqVNuQWIs04-ceApAI4TcMfDGd-v_X8tATLJUTm2wpeKHMK8x7nJhR8_5jbIJd87HISz8JH8mc7ydhKtphdD6Fj/s72-c/unrealscript_02a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-8863873042335740607</id><published>2013-04-05T09:24:00.000-03:00</published><updated>2014-01-31T13:53:07.111-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Actor"/><category scheme="http://www.blogger.com/atom/ns#" term="Actor Reference"/><category scheme="http://www.blogger.com/atom/ns#" term="cast"/><category scheme="http://www.blogger.com/atom/ns#" term="Object Reference"/><category scheme="http://www.blogger.com/atom/ns#" term="out"/><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript Object"/><title type='text'>Object and Actor References in UnrealScript</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Some beginners confuse an object with the variable that references the object. This lack of understanding can cause some errors when writing new UnrealScript codes.
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Analyze the code below and think about the values ​​that will be written on the screen.
&lt;/span&gt;
&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class TestObjReference extends UTGame;

var int xValue;
var int yValue;
var vector vectorStruct;
var Pawn pawnObj;
     
event PostBeginPlay()
{
  SetTimer(3);    
}

function Timer()
{        
  xValue = 10;
  yValue = 10;
  vectorStruct.X = 10;

          //Get a reference to the Player Pawn
  pawnObj = GetALocalPlayerController().Pawn;     
  pawnObj.health = 10;    
    
  ChangeValues( xValue, yValue, vectorStruct, pawnObj);
    
  Broadcast(self, &quot;xValue =&quot; @ xValue);
  Broadcast(self, &quot;yValue =&quot; @ yValue);
  Broadcast(self, &quot;vectorStruct.X =&quot; @ vectorStruct.X );
  Broadcast(self, &quot;pawnObj.health =&quot; @ pawnObj.health);    
}

function ChangeValues(int x, out int y, vector xVector, Pawn xPawn )
{
  x = 50;
  y = 50;
  xVector.X = 50;
  xPawn.health = 50;    
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
If you want to test this code in UDK just set the Game Type to &quot;TestObjReference&quot;. (UDK Menu: &lt;i&gt;View -&amp;gt; WorldProperties -&amp;gt; Game Type&lt;/i&gt;)
&lt;br /&gt;
&lt;br /&gt;
The primitive variables like &quot;int&quot; and &quot;float&quot; and the structs such as &quot;Vector&quot; and &quot;Rotator&quot; contains the values ​​that are assigned to them. But Objects and Actors variables are just references, so they do not contain the values ​​of objects. The image below represents the use of variables of this code in memory.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzjopjZ0FfDwYNUorH1Y4bnwak4mBHs5qXMogLxBRGhP7gDdF285Y6BGpyaVhslGDyZUP4cR2WSyX4GiQ3tC6272ozeIt5JugcWP-TI6FH_UyRyzjRAfeKfhqWxjkCHRP9iDYMDeukujyf/s1600/unrealscript_01a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzjopjZ0FfDwYNUorH1Y4bnwak4mBHs5qXMogLxBRGhP7gDdF285Y6BGpyaVhslGDyZUP4cR2WSyX4GiQ3tC6272ozeIt5JugcWP-TI6FH_UyRyzjRAfeKfhqWxjkCHRP9iDYMDeukujyf/s1600/unrealscript_01a.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;When you declare a variable of some class it starts with the value &quot;&lt;b&gt;None&lt;/b&gt;&quot;. This means that it does not reference any object. You can get a reference to an object or create one using the &quot;&lt;b&gt;New&lt;/b&gt;&quot; operator. If the variable references an Actor (or a subclass) you must use the &quot;&lt;b&gt;Spawn&lt;/b&gt;&quot; function to create a new object.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the image above we can see that although the variables &quot;pawnObj&quot; and &quot;xPawn&quot; are different they refer to the same object &lt;i&gt;Player Pawn&lt;/i&gt;, whereas the variables &quot;vectorStruct&quot; and &quot;xVector&quot; do not have any kind of relationship.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The variables &quot;xValue&quot; and &quot;x&quot; are independent whereas the variables &quot;yValue&quot; and &quot;y&quot; are related because the variable &quot;y&quot; was declared as &quot;&lt;b&gt;out&lt;/b&gt;&quot; in the function &lt;i&gt;ChangeValues()&lt;/i&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The image below shows the values ​​that will be written on the screen.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2Kz1GTD3lPBCp-TgAp2PVpELIgDg4klrsfcQqXCzqO-T3y6RitShPKC-Ee748Of_0_OeGNgtcEHRCApu3ee5vv_8QxKjWFupTUR3EnsawJd7ZI7e4WineZwal22bRPJXpdiI5NqmVS3hI/s1600/unrealscript_01b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2Kz1GTD3lPBCp-TgAp2PVpELIgDg4klrsfcQqXCzqO-T3y6RitShPKC-Ee748Of_0_OeGNgtcEHRCApu3ee5vv_8QxKjWFupTUR3EnsawJd7ZI7e4WineZwal22bRPJXpdiI5NqmVS3hI/s1600/unrealscript_01b.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;When you declare a variable of a specific class, this variable can also refer the subclasses. However, to access the variables and functions that belong to the subclasses is necessary to &quot;&lt;b&gt;cast&lt;/b&gt;&quot; this variable into the desired subclass.&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The code below shows a simple example of an Actor variable that references an object of the Pawn class. The cast is necessary to access the &quot;Health&quot; variable that belongs to the Pawn class.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function Timer()
{
  local Actor actorObj;

  actorObj = GetALocalPlayerController().Pawn;     

  Pawn(actorObj).health = 10;    
}
&lt;/code&gt;&lt;/pre&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8863873042335740607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8863873042335740607'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2013/04/object-and-actor-references-in.html' title='Object and Actor References in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzjopjZ0FfDwYNUorH1Y4bnwak4mBHs5qXMogLxBRGhP7gDdF285Y6BGpyaVhslGDyZUP4cR2WSyX4GiQ3tC6272ozeIt5JugcWP-TI6FH_UyRyzjRAfeKfhqWxjkCHRP9iDYMDeukujyf/s72-c/unrealscript_01a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-8762910182949715753</id><published>2012-06-28T06:48:00.000-03:00</published><updated>2012-07-06T11:28:32.886-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Conclusion of &quot;UnrealScript for Beginners&quot;</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxcew5huKXn8Yq_aNcXrfFhkJuZiZ8ofhjjOAmhswIrp9GyUNhoLM7omK-7qzupsMKfFUO7Cz6frlow7Is0CU9k7TQoW8cqlbrwFk0eMM6-Sh2C_S8UyCwvWXa-y_KGwAvYtd8T4l7_mo/s1600/UTbox.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxcew5huKXn8Yq_aNcXrfFhkJuZiZ8ofhjjOAmhswIrp9GyUNhoLM7omK-7qzupsMKfFUO7Cz6frlow7Is0CU9k7TQoW8cqlbrwFk0eMM6-Sh2C_S8UyCwvWXa-y_KGwAvYtd8T4l7_mo/s400/UTbox.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
In 1999, I had my first contact with the Unreal Engine through the Unreal Tournament game. I was very impressed with the graphics, music, artificial intelligence, weapons and game dynamics. When I remember this game, automatically the Intro music and the voice of the narrator at the beginning of the game start to echo in my mind.&lt;br /&gt;
&lt;br /&gt;
Nowadays, I admire the Unreal Engine by a programmer&#39;s perspective. It is fascinating the technology and complexity existent in the core of the Unreal Engine that was developed by the brilliant mind of &lt;a href=&quot;http://kotaku.com/5865951/the-quiet-tinkerer-who-makes-games-beautiful-finally-gets-his-due&quot;&gt;Tim Sweeney&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;I would like to thank Epic Games for creating this amazing engine and made it available through the UDK that allowed many people&#39;s dreams to become possible.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&quot;&lt;i&gt;The time has come to prove you are the best.&lt;/i&gt;&lt;/span&gt;&lt;i&gt;&lt;br style=&quot;font-family: Verdana,sans-serif;&quot; /&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To crush your enemies;&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;i&gt;to win the Tournament.&lt;/i&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;(Unreal Tournament 1 Intro)&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8762910182949715753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8762910182949715753'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/conclusion-of-unrealscript-for.html' title='Conclusion of &quot;UnrealScript for Beginners&quot;'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxcew5huKXn8Yq_aNcXrfFhkJuZiZ8ofhjjOAmhswIrp9GyUNhoLM7omK-7qzupsMKfFUO7Cz6frlow7Is0CU9k7TQoW8cqlbrwFk0eMM6-Sh2C_S8UyCwvWXa-y_KGwAvYtd8T4l7_mo/s72-c/UTbox.jpg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-6289818171630120745</id><published>2012-06-27T10:27:00.001-03:00</published><updated>2012-06-27T10:27:15.861-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_AIPawn class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The SPG_AIPawn class represents the bots that attack the player in the Platform Kit. The variables defined for this class are:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_AIPawn extends Pawn
      placeable;

// Dynamic light environment component to help speed up lighting calculations for the pawn
var(Pawn) const DynamicLightEnvironmentComponent LightEnvironment;

// Ground speed of the pawn, display as Ground Speed in the editor
var(Pawn) const float UserGroundSpeed&amp;lt;DisplayName=Ground Speed&amp;gt;;

// Explosion particle system to play when blowing up
var(Pawn) const ParticleSystem ExplosionParticleTemplate;

// Explosion sound to play
var(Pawn) const SoundCue ExplosionSoundCue;

// Explosion damage amount 
var(Pawn) const int ExplosionDamage;

// Archetyped pick up to drop
var(Pawn) const archetype DroppedPickup ArchetypedPickup;

// Percentage chance to drop pickups
var(Pawn) const float ChanceToDropPickup;

// Current enemy
var Actor Enemy;
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
There is an Archetype for the SPG_AIPawn class. The image below shows the specific variables of the SPG_AIPawn class.&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFK6tMW4jAg2QAnkiOqNxydpqiI5fYsdbvQTSbk9Tfjjt4gjaqQm9ggXM2E7bVeaXuLed7IIOOXAUy3cuff3xC9Z7CkIsUiN4cIA5x1SOIBg-pnxAspcj-Ckj8wV58HFzrYd-2J8fmFsw/s1600/us39a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;143&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFK6tMW4jAg2QAnkiOqNxydpqiI5fYsdbvQTSbk9Tfjjt4gjaqQm9ggXM2E7bVeaXuLed7IIOOXAUy3cuff3xC9Z7CkIsUiN4cIA5x1SOIBg-pnxAspcj-Ckj8wV58HFzrYd-2J8fmFsw/s400/us39a.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;Tick()&lt;/i&gt; function is executed every frame. In this function a reference to the player is stored in the &lt;i&gt;Enemy&lt;/i&gt; variable, if this has not been done.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
After that, if the bot is already walking on the ground (&lt;i&gt;Physics == PHYS_Walking&lt;/i&gt;), it gets the player&#39;s location and adjust its velocity and rotation to move toward the player.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;simulated function Tick(float DeltaTime)
{
    local PlayerController PlayerController;
    local Vector Direction;
    local Rotator NewRotation;

    Super.Tick(DeltaTime);

    // If we don&#39;t have an enemy yet...
    if (Enemy == None)
    {
        // Find the player controller in the world
        PlayerController = GetALocalPlayerController();

        if (PlayerController != None &amp;amp;&amp;amp; PlayerController.Pawn != None)
        {
            // Set the enemy to the player controller&#39;s pawn
            Enemy = PlayerController.Pawn;
        }
    }
    else if (Physics == PHYS_Walking)
    {
        // Find the direction in order for me to look at my enemy
        Direction = Enemy.Location - Location;

        // Only need to use the yaw from the direction
        NewRotation = Rotator(Direction);
        NewRotation.Pitch = 0;
        NewRotation.Roll = 0;

        // Set the rotation so that I look at the enemy
        SetRotation(NewRotation);

        // Set my velocity, so I move towards the enemy
        Velocity = Normal(Enemy.Location - Location) * UserGroundSpeed;

        // Set my acceleration, so I move towards the enemy
        Acceleration = Velocity;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy_cCU21AgNGpf4yJiFYeOySP-CcNyYIxfUPZsIS_7nFgOvB5QU5aSrMtzYEaBAeLfRd4BynUagGt93d4WBAyBjD1nildFFmOcugTM-W3Wp8UCwKQRzjpt7UPlr9IIbOo2TQ6_J4nvjog/s1600/us39b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;233&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiy_cCU21AgNGpf4yJiFYeOySP-CcNyYIxfUPZsIS_7nFgOvB5QU5aSrMtzYEaBAeLfRd4BynUagGt93d4WBAyBjD1nildFFmOcugTM-W3Wp8UCwKQRzjpt7UPlr9IIbOo2TQ6_J4nvjog/s400/us39b.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
When a bot collides with the player, the &lt;i&gt;Bump()&lt;/i&gt; function is executed. For more information about collision read the article: &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/11/collision-in-unrealscript.html&quot;&gt;Collision in UnrealScript&lt;/a&gt;&quot;. &lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The player, who is represented by the variable &lt;i&gt;Other&lt;/i&gt; in this function, receives damage whose value is set in the &lt;i&gt;ExplosionDamage&lt;/i&gt; variable. In the image of the Archetype we can see that the default value of this variable is 5.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The particles effect that represents the explosion is triggered and is played the sound of the explosion stored in the variable &lt;i&gt;ExplosionSoundCue&lt;/i&gt;. For more information about &lt;i&gt;SoundCue&lt;/i&gt;, read the article: &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/11/playing-sounds-in-unrealscript.html&quot;&gt;Playing Sounds in UnrealScript&lt;/a&gt;&quot;.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;event Bump(Actor Other, PrimitiveComponent OtherComp, Vector HitNormal)
{
    Super.Bump(Other, OtherComp, HitNormal);

    if (SPG_PlayerPawn(Other) != None)
    {
        // Apply damage to the bumped pawn
        Other.TakeDamage(ExplosionDamage, None, Location, Vect(0, 0, 0), class&#39;DamageType&#39;);

        // Play the particle effect
        if (ExplosionParticleTemplate != None)
        {
            WorldInfo.MyEmitterPool.SpawnEmitter(ExplosionParticleTemplate, Location);
        }

        // Play the explosion sound
        if (ExplosionSoundCue != None)
        {
            PlaySound(ExplosionSoundCue);
        }

        // Destroy the pawn
        Destroy();
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2RljAZPRPeRkJUI5CDUsj_70m8a6ZxHAKSwgUq24B926eWi84ZKjcTO5io4m3X3pPJaseaOJjY5l34SOOvqnOLQYfugaJZocwF-Sk4rC0MUuwNdCgC9A02uBn-usywI5YStGtMBpMTRM/s1600/us39c.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;369&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2RljAZPRPeRkJUI5CDUsj_70m8a6ZxHAKSwgUq24B926eWi84ZKjcTO5io4m3X3pPJaseaOJjY5l34SOOvqnOLQYfugaJZocwF-Sk4rC0MUuwNdCgC9A02uBn-usywI5YStGtMBpMTRM/s400/us39c.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
When a bot is eliminated by the player, the PlayDying() function is executed. In this function the physics of the bot is defined as &lt;i&gt;PHYS_RigidBody&lt;/i&gt; so that it falls to the ground.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
Is checked the possibility of the bot drop a health item, which is represented by the class &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/06/platformer-kit-spghealthpickup-class.html&quot;&gt;SPG_HealthPickup&lt;/a&gt;. This test is done with the expression: &quot;&lt;i&gt;FRand() &amp;lt;= ChanceToDropPickup&lt;/i&gt;&quot;. &lt;i&gt;FRand()&lt;/i&gt; is an UnrealScript function that returns a random value between 0.0 and 1.0. The variable &lt;i&gt;ChanceToDropPickup&lt;/i&gt; is defined in the Archetype with the value &quot;0.3&quot;. This means that there is a chance of 30% that a health item falls from the bot.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;simulated function PlayDying(class&amp;lt;DamageType&amp;gt; DamageType, vector HitLoc)
{
    local DroppedPickup DroppedPickup;

    Mesh.MinDistFactorForKinematicUpdate = 0.0;
    Mesh.ForceSkelUpdate();
    Mesh.SetTickGroup(TG_PostAsyncWork);
    CollisionComponent = Mesh;
    CylinderComponent.SetActorCollision(false, false);
    Mesh.SetActorCollision(true, false);
    Mesh.SetTraceBlocking(true, true);
    SetPawnRBChannels(true);

    SetPhysics(PHYS_RigidBody);

    Mesh.PhysicsWeight = 1.f;

    if (Mesh.bNotUpdatingKinematicDueToDistance)
    {
        Mesh.UpdateRBBonesFromSpaceBases(true, true);
    }

    Mesh.PhysicsAssetInstance.SetAllBodiesFixed(false);
    Mesh.bUpdateKinematicBonesFromAnimation = false;
    Mesh.WakeRigidBody();

    // Set the actor to automatically destroy in ten seconds.
    LifeSpan = 10.f;

    // Chance to drop a pick up
    if (ArchetypedPickup != None &amp;amp;&amp;amp; FRand() &amp;lt;= ChanceToDropPickup)
    {
        // Spawn a dropped pickup
        DroppedPickup = Spawn(ArchetypedPickup.Class,,, Location,, ArchetypedPickup);

        if (DroppedPickup != None)
        {
            // Set the dropped pick up to falling
            DroppedPickup.SetPhysics(PHYS_Falling);

            // Set the velocity of the dropped pickup to the toss velocity
            DroppedPickup.Velocity.X = 0;
            DroppedPickup.Velocity.Y = 0;
            DroppedPickup.Velocity.Z = RandRange(200.f, 250.f);
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7QFiO2HN6lOfnH_DnthSFaqJp5ZGx0LN3fRriZ8_jwIIbTgnwxszo7gstZmvpSeVIgj_kM_HYh7_gVIV8tNyfUAGC_P4CjviPBMYp4PLZux2q3Or2Ic14CgAEOkBlESHTMWmXOr72cbs/s1600/us39d.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;227&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7QFiO2HN6lOfnH_DnthSFaqJp5ZGx0LN3fRriZ8_jwIIbTgnwxszo7gstZmvpSeVIgj_kM_HYh7_gVIV8tNyfUAGC_P4CjviPBMYp4PLZux2q3Or2Ic14CgAEOkBlESHTMWmXOr72cbs/s400/us39d.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/6289818171630120745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/6289818171630120745'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spgaipawn-class.html' title='Platformer Kit: SPG_AIPawn class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFK6tMW4jAg2QAnkiOqNxydpqiI5fYsdbvQTSbk9Tfjjt4gjaqQm9ggXM2E7bVeaXuLed7IIOOXAUy3cuff3xC9Z7CkIsUiN4cIA5x1SOIBg-pnxAspcj-Ckj8wV58HFzrYd-2J8fmFsw/s72-c/us39a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-1280531985894558795</id><published>2012-06-26T14:52:00.001-03:00</published><updated>2012-06-26T14:52:51.705-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_Weapon class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The SPG_Weapon class represents the weapon used in the Platformer Kit. It is based on the &lt;i&gt;Link Gun&lt;/i&gt; weapon of Unreal Tournament, but only has the option of shooting with projectile.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
If you do not know about the Weapon class first read the article: &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/02/weapon-class-unrealscript.html&quot;&gt;Weapon Class (UnrealScript)&lt;/a&gt;&quot;.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The variables of the SPG_Weapon class are available for changing in the editor.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_Weapon extends Weapon;

// Name of the socket which represents the muzzle socket
var(Weapon) const Name MuzzleSocketName;

// Particle system representing the muzzle flash
var(Weapon) const ParticleSystemComponent MuzzleFlash;

// Projectile classes that this weapon fires. DisplayName lets the editor show this as WeaponProjectiles
var(Weapon) const array&amp;lt; class&amp;lt;Projectile&amp;gt; &amp;gt; Projectiles&amp;lt;DisplayName=Weapon Projectiles&amp;gt;;

// Sounds to play back when the weapon is fired
var(Weapon) const array&amp;lt;SoundCue&amp;gt; WeaponFireSounds;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
An Archetype was also created for SPG_Weapon class. The image below shows the values ​​of some variables.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg136LNEkZctc-yvN8tU3Jrnw5bYqYyVdPLheSLpcnhod5BCt-Pwp_NnOdnQ04wvQNlpgIpGhmS425w7htaKzEk_yvRc3caEljznQHuf73PTBHqiu5BL3SklmpqNp4yaucNGJI7kHZYOlM/s1600/us38a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;141&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg136LNEkZctc-yvN8tU3Jrnw5bYqYyVdPLheSLpcnhod5BCt-Pwp_NnOdnQ04wvQNlpgIpGhmS425w7htaKzEk_yvRc3caEljznQHuf73PTBHqiu5BL3SklmpqNp4yaucNGJI7kHZYOlM/s400/us38a.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The SPG_Weapon class uses two &lt;i&gt;Sockets&lt;/i&gt;. One to define the position in the 3D model of the weapon where the projectile is fired. The other &lt;i&gt;Socket&lt;/i&gt; belongs to the SPG_PlayerPawn class and defines the position where the weapon must stay relative to the player. To understand more about &lt;i&gt;Sockets&lt;/i&gt;, read the article at UDN: &quot;&lt;a href=&quot;http://udn.epicgames.com/Three/SkeletalMeshSockets.html&quot;&gt;Skeletal Mesh Sockets&lt;/a&gt;&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the &lt;i&gt;PostBeginPlay()&lt;/i&gt; function, the &lt;i&gt;Particle System Component&lt;/i&gt; represented by the &quot;MuzzleFlash&quot; variable is attached to the &lt;i&gt;Socket&lt;/i&gt; of the weapon. The weapon is attached to the player in the &lt;i&gt;ClientGivenTo()&lt;/i&gt; function.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;simulated event PostBeginPlay()
{
    local SkeletalMeshComponent SkeletalMeshComponent;

    Super.PostBeginPlay();

    if (MuzzleFlash != None)
    {
        SkeletalMeshComponent = SkeletalMeshComponent(Mesh);
        if (SkeletalMeshComponent != None &amp;amp;&amp;amp; SkeletalMeshComponent.GetSocketByName(MuzzleSocketName) != None)
        {
            SkeletalMeshComponent.AttachComponentToSocket(MuzzleFlash, MuzzleSocketName);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
One function that is executed when the weapon is fired is the &lt;i&gt;PlayFireEffects()&lt;/i&gt;. It is responsible for activating the Particles System and play the weapon firing sound.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
For more information about Particles Systems, read the article at UDN: &quot;&lt;a href=&quot;http://udn.epicgames.com/Three/ParticleSystemsHome.html&quot;&gt;Particles Systems&lt;/a&gt;&quot;.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
Below is the image when the weapon is fired and the code of the &lt;i&gt;PlayFireEffects()&lt;/i&gt; function.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcEVd_lZjgRuQdN0lXoTVcvlR8RNrwl_vMtg_yJpCUCL1XImJJJz_kS8BQU7EMrULjmkEP36DM31GwB_C5YRFBQqL-G8vzdWkozmxJz46odngugnkV22_B9pG93NMEzp4E4l4O8Sh9Kck/s1600/us38b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcEVd_lZjgRuQdN0lXoTVcvlR8RNrwl_vMtg_yJpCUCL1XImJJJz_kS8BQU7EMrULjmkEP36DM31GwB_C5YRFBQqL-G8vzdWkozmxJz46odngugnkV22_B9pG93NMEzp4E4l4O8Sh9Kck/s1600/us38b.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;simulated function PlayFireEffects(byte FireModeNum, optional vector HitLocation)
{
    if (MuzzleFlash != None)
    {
        // Activate the muzzle flash
        MuzzleFlash.ActivateSystem();
    }

    // Play back weapon fire sound if FireModeNum is within the array bounds and if the 
    // weapon fire sound in that array index is not none
    if (FireModeNum &amp;lt; WeaponFireSounds.Length &amp;amp;&amp;amp; WeaponFireSounds[FireModeNum] != None &amp;amp;&amp;amp; Instigator != None)
    {
        Instigator.PlaySound(WeaponFireSounds[FireModeNum]);
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The other function that is executed when the weapon is fired is the &lt;i&gt;ProjectileFire()&lt;/i&gt;. It is responsible for creating a new projectile and start it in the correct position and direction.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The position of the projectile is obtained from the &lt;/span&gt;&lt;i style=&quot;font-family: Verdana,sans-serif;&quot;&gt;GetWeaponStartTraceLocation()&lt;/i&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt; function of the SPG_PlayerPawn class, which is represented in the code by the variable &lt;/span&gt;&lt;i style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Instigator&lt;/i&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;simulated function Projectile ProjectileFire()
{
    local Vector SpawnLocation;
    local Rotator SpawnRotation;
    local class&amp;lt;Projectile&amp;gt; ProjectileClass;
    local Projectile SpawnedProjectile;

    // tell remote clients that we fired, to trigger effects
    IncrementFlashCount();

    // Only allow servers to spawn projectiles
    if (Role == ROLE_Authority)
    {
        // This is where we would spawn the projectile
        SpawnLocation = Instigator.GetWeaponStartTraceLocation();

        // This is the rotation we should spawn the projectile
        SpawnRotation = GetAdjustedAim(SpawnLocation);

        // Get the projectile class
        ProjectileClass = GetProjectileClass();
        if (ProjectileClass != None)
        {
            // Spawn the projectile setting the projectile&#39;s owner to myself
            SpawnedProjectile = Spawn(ProjectileClass, Self,, SpawnLocation, SpawnRotation);

            // Check if we&#39;ve spawned the projectile, and that it isn&#39;t going to be deleted
            if (SpawnedProjectile != None &amp;amp;&amp;amp; !SpawnedProjectile.bDeleteMe)
            {
                // Initialize the projectile
                SpawnedProjectile.Init(Vector(SpawnRotation));
            }
        }
      
        // Return it up the line
        return SpawnedProjectile;
    }

    return None;
}&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBnF2qbRA2Ia1eOlwHtE1Bxo-SxBv7ffsREAMk5TGvTmmGfGSyNFFAlIjr2YfdlJpyUrWjbSR2MZ-qkaH4Ef16BXBhnXgx23b5Am3fIpFPFWaKWKJn6yo9QXczMvvNHyjr8VE_N83Na4I/s1600/us38c.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;265&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBnF2qbRA2Ia1eOlwHtE1Bxo-SxBv7ffsREAMk5TGvTmmGfGSyNFFAlIjr2YfdlJpyUrWjbSR2MZ-qkaH4Ef16BXBhnXgx23b5Am3fIpFPFWaKWKJn6yo9QXczMvvNHyjr8VE_N83Na4I/s400/us38c.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1280531985894558795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1280531985894558795'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spgweapon-class.html' title='Platformer Kit: SPG_Weapon class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg136LNEkZctc-yvN8tU3Jrnw5bYqYyVdPLheSLpcnhod5BCt-Pwp_NnOdnQ04wvQNlpgIpGhmS425w7htaKzEk_yvRc3caEljznQHuf73PTBHqiu5BL3SklmpqNp4yaucNGJI7kHZYOlM/s72-c/us38a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-8118602827129409344</id><published>2012-06-25T13:17:00.000-03:00</published><updated>2012-06-25T13:17:58.179-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_PlayerPawn class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The SPG_PlayerPawn class represents the player&#39;s character. If you do not know about the Pawn class first read the article: &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/10/pawn-class-unrealscript.html&quot;&gt;Pawn Class (UnrealScript)&lt;/a&gt;&quot;.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The variables below of the SPG_PlayerPawn class are available for changing in the editor.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_PlayerPawn extends Pawn;

// Dynamic light environment component to help speed up lighting calculations for the pawn
var(Pawn) const DynamicLightEnvironmentComponent LightEnvironment;

// How fast a pawn turns
var(Pawn) const float TurnRate;

// How high the pawn jumps
var(Pawn) const float JumpHeight;

// Socket to use for attaching weapons
var(Pawn) const Name WeaponSocketName;

// Height to set the collision cylinder when crouching
var(Pawn) const float CrouchHeightOverride&amp;lt;DisplayName=Crouch Height&amp;gt;;

// Radius to set the collision cylinder when crouching
var(Pawn) const float CrouchRadiusOverride&amp;lt;DisplayName=Crouch Radius&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
An Archetype was also created for SPG_PlayerPawn class. The image below shows the values ​​of some variables.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ2uiPVVRD4dmK3ve0xZtKVFAHuqnAjqX-rujfC5A_IGx0o1HOO7HVfakASVIK7GU6reGResVesDEsTR00p5BJJg2xKUGNpkCWe7aMFPR5YryANO3c9t5F-aOG3uCfU_hGaXFAZaldYGY/s1600/us37a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;147&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ2uiPVVRD4dmK3ve0xZtKVFAHuqnAjqX-rujfC5A_IGx0o1HOO7HVfakASVIK7GU6reGResVesDEsTR00p5BJJg2xKUGNpkCWe7aMFPR5YryANO3c9t5F-aOG3uCfU_hGaXFAZaldYGY/s400/us37a.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;FaceRotation()&lt;/i&gt; function of the SPG_PlayerPawn class is called from the &lt;i&gt;UpdateRotation()&lt;/i&gt; function of the &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/06/platformer-kit-spgplayercontroller.html&quot;&gt;SPG_PlayerController&lt;/a&gt; class.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;This function will adjust two types of rotation: the rotation of the aim and the rotation of the character.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The rotation of the aim is adjusted from the variable &quot;&lt;i&gt;AimNode.Aim.Y&lt;/i&gt;&quot; based on the value of the &lt;i&gt;Pitch&lt;/i&gt; variable of the Rotator that is passed as a parameter. The variable &lt;i&gt;AimNode&lt;/i&gt; is of the &lt;a href=&quot;http://udn.epicgames.com/Three/AnimationNodes.html&quot;&gt;AnimNodeAimOffset&lt;/a&gt; type.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The rotation of the character is done ​​based on the value of the &lt;i&gt;Yaw&lt;/i&gt; variable of the Rotator that is passed as a parameter, using the &lt;i&gt;SetRotation()&lt;/i&gt; function of the Pawn class.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;simulated function FaceRotation(Rotator NewRotation, float DeltaTime)
{
    local Rotator FacingRotation;

    // Set the desired yaw the new rotation yaw
    if (NewRotation.Yaw != 0)
    {
        DesiredYaw = NewRotation.Yaw;
    }

    // If the current yaw doesn&#39;t match the desired yaw, then interpolate towards it
    if (CurrentYaw != DesiredYaw)
    {
        CurrentYaw = Lerp(CurrentYaw, DesiredYaw, TurnRate * DeltaTime);
    }

    // If we have a valid aim offset node
    if (AimNode != None)
    {
        // Clamp the current pitch to the view pitch min and view pitch max
        CurrentPitch = Clamp(CurrentPitch + NewRotation.Pitch, ViewPitchMin, ViewPitchMax);

        if (CurrentPitch &amp;gt; 0.f)
        {
            // Handle when we&#39;re aiming up
            AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMax;
        }
        else if (CurrentPitch &amp;lt; 0.f)
        {
            // Handle when we&#39;re aiming down
            AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMin;
           
            if (AimNode.Aim.Y &amp;gt; 0.f)
            {
                AimNode.Aim.Y *= -1.f;
            }
        }
        else
        {
            // Handle when we&#39;re aiming straight forward
            AimNode.Aim.Y = 0.f;
        }
    }

    // Update the facing rotation
    FacingRotation.Pitch = 0;
    FacingRotation.Yaw = CurrentYaw;
    FacingRotation.Roll = 0;

    SetRotation(FacingRotation);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;DoJump()&lt;/i&gt; function is called to perform the jump of the character. It takes into account the different &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/02/using-physics-in-unrealscript.html&quot;&gt;types of Physics&lt;/a&gt; that the character can be.&lt;br /&gt;
&lt;br /&gt;
In essence, the velocity along the Z axis (up) receives the value of the &lt;i&gt;JumpHeight&lt;/i&gt; variable that was defined for this class and can be adjusted in the Archetype. After it is checked whether the player is on a moving platform. If true, then the velocitity of the platform (&lt;i&gt;Base.Velocity.Z&lt;/i&gt;) influences the velocity of the jump of the player.
&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function bool DoJump(bool bUpdating)
{
    if (bJumpCapable &amp;amp;&amp;amp; !bIsCrouched &amp;amp;&amp;amp; !bWantsToCrouch &amp;amp;&amp;amp; (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
     {
        if (Physics == PHYS_Spider)
        {
            Velocity = JumpHeight * Floor;
        }
        else if (Physics == PHYS_Ladder)
        {
            Velocity.Z = 0.f;
        }
        else
        {
            Velocity.Z = JumpHeight;
        }

        if (Base != None &amp;amp;&amp;amp; !Base.bWorldGeometry &amp;amp;&amp;amp; Base.Velocity.Z &amp;gt; 0.f)
        {
            Velocity.Z += Base.Velocity.Z;
        }

        SetPhysics(PHYS_Falling);
        return true;
    }

    return false;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY7bcY4gw24IUBL7JwDjUKaLTDx6Hvf-b_cEM1Wzv1jaga5XDvaycjSyxQw4GmBsl01PC7c-NN9vGHNkXOp9iqxb8O6M77crRT6aM5D83zSOHxP40JF-M4QRROBoYa23hz2WH-qAVTPew/s1600/us37b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;215&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY7bcY4gw24IUBL7JwDjUKaLTDx6Hvf-b_cEM1Wzv1jaga5XDvaycjSyxQw4GmBsl01PC7c-NN9vGHNkXOp9iqxb8O6M77crRT6aM5D83zSOHxP40JF-M4QRROBoYa23hz2WH-qAVTPew/s400/us37b.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8118602827129409344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8118602827129409344'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spgplayerpawn-class.html' title='Platformer Kit: SPG_PlayerPawn class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ2uiPVVRD4dmK3ve0xZtKVFAHuqnAjqX-rujfC5A_IGx0o1HOO7HVfakASVIK7GU6reGResVesDEsTR00p5BJJg2xKUGNpkCWe7aMFPR5YryANO3c9t5F-aOG3uCfU_hGaXFAZaldYGY/s72-c/us37a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-4496602821789957373</id><published>2012-06-22T16:11:00.000-03:00</published><updated>2012-06-22T16:11:13.369-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_PlayerController class (UnrealScript)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The SPG_PlayerController class is responsible for adapting the commands of the player to the platform style.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If you do not know about the Controller class, first read the article: &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/10/controller-class-unrealscript.html&quot;&gt;Controller Class (UnrealScript)&lt;/a&gt;&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;One of the functions that is overridden is the UpdateRotation() whose code is below.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function UpdateRotation(float DeltaTime)
{
    local Rotator DeltaRot;

    // Set the delta rotation to that of the desired rotation, as the desired rotation represents
    // the rotation derived from the acceleration of the pawn
    DeltaRot = DesiredRotation;

    // Set the delta pitch to read from the look up input
    DeltaRot.Pitch = PlayerInput.aLookUp;

    // Never need to roll the delta rotation
    DeltaRot.Roll = 0;

    // Shake the camera if necessary
    ViewShake(DeltaTime);

    // If we have a pawn, update its facing rotation
    if (Pawn != None)
    {
        Pawn.FaceRotation(DeltaRot, DeltaTime);
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
There are two types of rotations that occur in the Platformer Kit. One is the rotation that occurs when the player changes the direction he is moving. The other is the rotation of the aim that changes the direction of the fire.&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The rotation of the player is manipulated through the use of the variable &lt;i&gt;DesiredRotation&lt;/i&gt;. The rotation of the aim is obtained from the variable &lt;i&gt;aLookUp&lt;/i&gt; of the &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/12/playerinput-class-unrealscript.html&quot;&gt;PlayerInput class&lt;/a&gt;. The variable aLookUp maps the forward and backward movement of the Mouse. The image below shows the player looking upwards.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The FaceRotation() function which will be called from the Pawn object, is that defined in the SPG_PlayerPawn class.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipNbAFMh_arRNZSAqPF-32-5eQlb9F8rSDAFnwbbzF0n5aNEBv5ZoAP_FFRJA0Tc9I3UFSnQkV_6bBnK9L1d0HtbS-jluE4wlDh5RY7X2271KG_3GiMUxDhwr8gRooxO9SMXZm1BLDjA8/s1600/us36.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipNbAFMh_arRNZSAqPF-32-5eQlb9F8rSDAFnwbbzF0n5aNEBv5ZoAP_FFRJA0Tc9I3UFSnQkV_6bBnK9L1d0HtbS-jluE4wlDh5RY7X2271KG_3GiMUxDhwr8gRooxO9SMXZm1BLDjA8/s1600/us36.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the PlayerMove() function an acceleration is calculated based on the variable &quot;&lt;i&gt;PlayerInput.aStrafe&lt;/i&gt;&quot; which &lt;/span&gt;&lt;span class=&quot;short_text&quot; id=&quot;result_box&quot; lang=&quot;en&quot; style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;span class=&quot;hps&quot;&gt;represents&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt; the horizontal movement. This acceleration is stored in the variable of type &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/10/using-vectors-in-unrealscript.html&quot;&gt;Vector&lt;/a&gt; &quot;NewAccel&quot;. The function code is below.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;state PlayerWalking
{
    function PlayerMove(float DeltaTime)
    {
        local Vector X, Y, Z, NewAccel, CameraLocation;
        local Rotator OldRotation, CameraRotation;
        local bool bSaveJump;

        // If we don&#39;t have a pawn to control, then we should go to the dead state
        if (Pawn == None)
        {
            GotoState(&#39;Dead&#39;);
        }
        else
        {
            // Grab the camera view point as we want to have movement aligned to the camera
            PlayerCamera.GetCameraViewPoint(CameraLocation, CameraRotation);

            // Get the individual axes of the rotation
            GetAxes(CameraRotation, X, Y, Z);

            // Update acceleration
            NewAccel = PlayerInput.aStrafe * Y;
            NewAccel.Z = 0;
            NewAccel = Pawn.AccelRate * Normal(NewAccel);

            // Set the desired rotation
            DesiredRotation = Rotator(NewAccel);

            // Update rotation
            OldRotation = Rotation;
            UpdateRotation(DeltaTime);

            // Update crouch
            Pawn.ShouldCrouch(bool(bDuck));

            // Handle jumping
            if (bPressedJump &amp;amp;&amp;amp; Pawn.CannotJumpNow())
            {
                bSaveJump = true;
                bPressedJump = false;
            }
            else
            {
                bSaveJump = false;
            }

            // Update the movement, either replicate it or process it
            if (Role &amp;lt; ROLE_Authority)
            {
                ReplicateMove(DeltaTime, NewAccel, DCLICK_None, OldRotation - Rotation);
            }
            else
            {
                ProcessMove(DeltaTime, NewAccel, DCLICK_None, OldRotation - Rotation);
            }

            bPressedJump = bSaveJump;
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;At the end of the PlayerMove() function there is the following test: &quot;&lt;i&gt;if (Role &amp;lt; ROLE_Authority)&lt;/i&gt;&quot;. This is used to check if the game is a client that is using a server. If this code is running on a server or in a single player game then the value of the &quot;Role&quot; variable will be equal to &quot;ROLE_Authority.&quot;&lt;/span&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/4496602821789957373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/4496602821789957373'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spgplayercontroller.html' title='Platformer Kit: SPG_PlayerController class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipNbAFMh_arRNZSAqPF-32-5eQlb9F8rSDAFnwbbzF0n5aNEBv5ZoAP_FFRJA0Tc9I3UFSnQkV_6bBnK9L1d0HtbS-jluE4wlDh5RY7X2271KG_3GiMUxDhwr8gRooxO9SMXZm1BLDjA8/s72-c/us36.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-8697024430162585111</id><published>2012-06-21T16:22:00.000-03:00</published><updated>2012-06-21T16:22:35.317-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_GameInfo class (UnrealScript)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The main adjustments of the SPG_GameInfo class were done to enable the use of Archetypes of the player&#39;s Pawn and Weapon classes.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;This class contains the references of the Archetypes in the DefaultPawnArchetype and DefaultWeaponArchetype variables.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_GameInfo extends SimpleGame;

// Variable which references the default pawn archetype stored within a package
var() const archetype Pawn DefaultPawnArchetype;
// Variable which references the default weapon archetype stored within a package
var() const archetype Weapon DefaultWeaponArchetype;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If you do not know the GameInfo class, take a look at my article, &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/11/gameinfo-class-unrealscript.html&quot;&gt;GameInfo Class (UnrealScript)&lt;/a&gt;&quot;. &lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The SPG_GameInfo class overrides the SpawnDefaultPawnFor() function so that the instance of the player&#39;s Pawn class is created based on the Archetype.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function Pawn SpawnDefaultPawnFor(Controller NewPlayer, NavigationPoint StartSpot)
{
    local Rotator StartRotation;
    local Pawn SpawnedPawn;

    // Quick exit if NewPlayer is none or if StartSpot is none
    if (NewPlayer == None || StartSpot == None)
    {
        return None;
    }

    // Only the start spot&#39;s yaw from its rotation is required
    StartRotation = Rot(0, 0, 0);
    StartRotation.Yaw = StartSpot.Rotation.Yaw;

    // Spawn the default pawn archetype at the start spot&#39;s location and the start rotation defined above
    // Set SpawnedPawn to the spawned
    SpawnedPawn = Spawn(DefaultPawnArchetype.Class,,, StartSpot.Location, StartRotation, DefaultPawnArchetype);

    // Return the value of SpawnedPawn
    return SpawnedPawn;
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The SpawnDefaultPawnFor() function uses a local variable of type Rotator called StartRotation to get only the rotation on the yaw axis from the StartSpot of the game. For more information about rotation, read my article: &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/01/using-rotators-in-unrealscript.html&quot;&gt;Using Rotators in UnrealScript&lt;/a&gt;&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
After that, it creates a new instance of Pawn based on the Archetype &quot;DefaultPawnArchetype&quot; using the Spawn() function.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Another function that is overridden in the SPG_GameInfo class is the AddDefaultInventory(). In this function is obtained a reference of the &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/06/platformer-kit-spginventorymanager.html&quot;&gt;SPG_InventoryManager&lt;/a&gt; class in order to create the weapon based on the Archetype DefaultWeaponArchetype.&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;event AddDefaultInventory(Pawn P)
{
    local SPG_InventoryManager SPG_InventoryManager;

    Super.AddDefaultInventory(P);

    // Ensure that we have a valid default weapon archetype
    if (DefaultWeaponArchetype != None)
    {
        // Get the inventory manager
        SPG_InventoryManager = SPG_InventoryManager(P.InvManager);
        if (SPG_InventoryManager != None)
        {
            // Create the inventory from the archetype
            SPG_InventoryManager.CreateInventoryArchetype(DefaultWeaponArchetype, false);
        }
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
In the &lt;i&gt;defaultproperties&lt;/i&gt; block are specified the Archetypes of the Pawn and Weapon, besides the classes responsible for the HUD and the PlayerController.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;defaultproperties
{
    // What player controller class to create for the player
    PlayerControllerClass=class&#39;SPG_PlayerController&#39;
    // What default pawn archetype to spawn for the player
    DefaultPawnArchetype=SPG_PlayerPawn&#39;StarterPlatformGameContent.Archetypes.PlayerPawn&#39;
    // What default weapon archetype to spawn for the player
    DefaultWeaponArchetype=SPG_Weapon&#39;StarterPlatformGameContent.Archetypes.LinkGunWeapon&#39;
    // What HUD class to create for the player
    HUDType=class&#39;SPG_HUD&#39;
}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8697024430162585111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8697024430162585111'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spggameinfo-class.html' title='Platformer Kit: SPG_GameInfo class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-1684748687525043163</id><published>2012-06-19T16:57:00.000-03:00</published><updated>2012-06-19T17:01:33.803-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_InventoryManager class (UnrealScript)</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The SPG_InventoryManager class exists to allow the creation of inventory items based on Archetypes. In the Platformer Kit it is used to create the weapon of the player.&lt;br /&gt;&lt;br /&gt;The class code is below:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_InventoryManager extends InventoryManager;

simulated function Inventory CreateInventoryArchetype(Inventory NewInventoryItemArchetype, optional bool bDoNotActivate)
{
    local Inventory    Inv;
  
    // Ensure the inventory archetype is valid
    if (NewInventoryItemArchetype != None)
    {
        // Spawn the inventory archetype
        Inv = Spawn(NewInventoryItemArchetype.Class, Owner,,,, NewInventoryItemArchetype);
      
        // Spawned the inventory, and add the inventory
        if (Inv != None &amp;amp;&amp;amp; !AddInventory(Inv, bDoNotActivate))
        {
            // Unable to add the inventory, so destroy the spawned inventory
            Inv.Destroy();
            Inv = None;
        }
    }

    // Return the spawned inventory
    return Inv;
}

defaultproperties
{
    // Create the pending fire array
    PendingFire(0)=0
    PendingFire(1)=0
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;CreateInventoryArchetype()&lt;/i&gt; function is called from the SPG_GameInfo class. It uses the &lt;i&gt;Spawn()&lt;/i&gt; function to create an instance of the Inventory class based on the Archetype&amp;nbsp; received as parameter.&lt;br /&gt;
&lt;br /&gt;
The Spawn() function is defined in the Actor class and has the following parameters:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;native noexport final function coerce actor Spawn
(
    class&amp;lt;actor&amp;gt;      SpawnClass,
    optional actor    SpawnOwner,
    optional name     SpawnTag,
    optional vector   SpawnLocation,
    optional rotator  SpawnRotation,
    optional Actor    ActorTemplate,
    optional bool     bNoCollisionFail
);&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Once created the instance of Inventory, it is added to the player&#39;s inventory through the AddInventory() function. You can find the code of this function in my article &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/02/pickupfactory-and-inventory-in.html&quot;&gt;PickupFactory and Inventory in UnrealScript&lt;/a&gt;&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If for some reason it is not possible to add the Inventory, the Destroy() function should be called to remove the object from memory. The Destroy() function is not executed immediately, so you need to assign &quot;None&quot; to the variable after the call to the Destroy() function.&lt;/span&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1684748687525043163'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1684748687525043163'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spginventorymanager.html' title='Platformer Kit: SPG_InventoryManager class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-6265959529281310191</id><published>2012-06-15T14:21:00.000-03:00</published><updated>2012-06-15T14:24:45.079-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_HealthPickup class (UnrealScript)</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFB-rK9kx3N5BfGGU1-TqHuofVNpQAWv3LPSVeKPgKOFP-F24A2RwglZzUcwUG59QLNJSbdFrfSJS-3PTqAnu5rdy1Vpyd-6lXLEco5IKhXX5bPHoUe4IztRMnS8EBiZ7vLkLS2BghUp0/s1600/us33a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFB-rK9kx3N5BfGGU1-TqHuofVNpQAWv3LPSVeKPgKOFP-F24A2RwglZzUcwUG59QLNJSbdFrfSJS-3PTqAnu5rdy1Vpyd-6lXLEco5IKhXX5bPHoUe4IztRMnS8EBiZ7vLkLS2BghUp0/s1600/us33a.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;SPG_HealthPickup&lt;/i&gt; class is used to represent a health item that can be dropped from an enemy when he dies. This class is a subclass of DroppedPickup. Its variables are:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_HealthPickup extends DroppedPickup
      placeable;

// Static mesh used by the pick up
var(HealthPickup) const StaticMeshComponent Mesh;

// Sound to play when the pick up is picked up by a pawn
var(HealthPickup) const SoundCue PickupSound;

// How much health to give to the pawn when picked up
var(HealthPickup) const int HealthToGive;&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The &lt;a href=&quot;http://udn.epicgames.com/Three/DevelopmentKitGemsPlatformerStarterKit.html&quot;&gt;Platformer Starter Kit&lt;/a&gt; also uses an &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/04/using-archetypes-in-unrealscript.html&quot;&gt;Archetype&lt;/a&gt; of this class to ease changes in the values ​​of its variables.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The image below shows the default values ​​of the Archetype of the &lt;i&gt;SPG_HealthPickup&lt;/i&gt; class.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi87wHmbOS7MnPlSMlut4bO1DnozYwChKFJfBZ8d5nsE2o0JyyHmDtzNj8SyV5DSg5F_881jAKgFJnQe7H112v6BgcpMkNOJPYGufcQ3z4zMQ_3U45toZd5AwvfI4Ri9rBJgu-5j1bCbkY/s1600/us33b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;207&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi87wHmbOS7MnPlSMlut4bO1DnozYwChKFJfBZ8d5nsE2o0JyyHmDtzNj8SyV5DSg5F_881jAKgFJnQe7H112v6BgcpMkNOJPYGufcQ3z4zMQ_3U45toZd5AwvfI4Ri9rBJgu-5j1bCbkY/s400/us33b.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
If you know nothing about Pickups, I recommend reading my article &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/02/pickupfactory-and-inventory-in.html&quot;&gt;PickupFactory and Inventory in UnrealScript&lt;/a&gt;&quot;.&lt;br /&gt;
&lt;br /&gt;
The &quot;GiveTo(Pawn P)&quot; function is called when the player gets an item. It just plays a sound and gives more health to the player:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;function GiveTo(Pawn P)
{
    // Play sound
    if (PickupSound != None)
    {
        PlaySound(PickupSound);        
    }

    // Add health to the player, but clamp it to the pawn&#39;s maximum health
    P.Health = Min(P.Health + HealthToGive, P.HealthMax);

    // Handle the rest of pick up
    PickedUpBy(P);
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The &quot;&lt;i&gt;int Min(int A, int B)&lt;/i&gt;&quot; function returns the smallest number between two integers and is used to prevent the player&#39;s health exceeds the maximum value. &lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The &quot;&lt;i&gt;PickedUpBy(Pawn P)&lt;/i&gt;&quot; function belongs to the &lt;i&gt;DroppedPickup&lt;/i&gt; class and it just calls the &quot;&lt;i&gt;Destroy()&lt;/i&gt;&quot; function to remove this Pickup from the game.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;SPG_HealthPickup&lt;/i&gt; class overrides the &quot;&lt;i&gt;ValidTouch(Pawn Other)&lt;/i&gt;&quot; function, which is within the state &quot;&lt;i&gt;Pickup&lt;/i&gt;&quot; of the &lt;i&gt;DroppedPickup&lt;/i&gt; class, with a simpler version of the function. This function is called every time there is a collision with an object of type &lt;i&gt;Pawn&lt;/i&gt; to check if it is the player who is picking up the item.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;auto state Pickup
{
    function bool ValidTouch(Pawn Other)
    {
        // make sure its a live player
        if (Other == None || !Other.bCanPickupInventory || (Other.DrivenVehicle == None &amp;amp;&amp;amp; Other.Controller == None))
        {
            return false;
        }

        // make sure thrower doesn&#39;t run over own weapon
        if (Physics == PHYS_Falling &amp;amp;&amp;amp; Other == Instigator &amp;amp;&amp;amp; Velocity.Z &amp;gt; 0)
        {
            return false;
        }

        return true;
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
Finally, we have the &lt;i&gt;defaultproperties&lt;/i&gt; block whose code is below. It defined an object of &lt;i&gt;StaticMeshComponent&lt;/i&gt; type with the name MyStaticMeshComponent. If you look at the image of the Archetype that was created for this class, the &lt;i&gt;Mesh&lt;/i&gt; property&amp;nbsp; is associated with the &lt;b&gt;MyStaticMeshComponent&lt;/b&gt; object that will be used as a component, using &quot;:&quot; and the name of the object.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;defaultproperties
{
    // Remove the sprite component
    Components.Remove(Sprite);

    // Add the static mesh component
    Begin Object Class=StaticMeshComponent Name=MyStaticMeshComponent
    End Object
    Mesh=MyStaticMeshComponent
    Components.Add(MyStaticMeshComponent);
}&lt;/code&gt;&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/6265959529281310191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/6265959529281310191'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spghealthpickup-class.html' title='Platformer Kit: SPG_HealthPickup class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFB-rK9kx3N5BfGGU1-TqHuofVNpQAWv3LPSVeKPgKOFP-F24A2RwglZzUcwUG59QLNJSbdFrfSJS-3PTqAnu5rdy1Vpyd-6lXLEco5IKhXX5bPHoUe4IztRMnS8EBiZ7vLkLS2BghUp0/s72-c/us33a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-448306836936076879</id><published>2012-06-08T12:06:00.001-03:00</published><updated>2012-06-08T12:06:48.807-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_Camera class (UnrealScript)</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7iNFMYQHQGyI7cptC-tlOMBWEHc1M9gGr-gg2ZKQat3L5_NWcN1aWa-y8dlfuPuVzIwbmUq7ItPvPKfTuA9A2VJ5x1vkJy-6DIyO_Ftbnex-icOOan3pTjNlF7K7EbHMhMlJwAXAc37w/s1600/us32a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7iNFMYQHQGyI7cptC-tlOMBWEHc1M9gGr-gg2ZKQat3L5_NWcN1aWa-y8dlfuPuVzIwbmUq7ItPvPKfTuA9A2VJ5x1vkJy-6DIyO_Ftbnex-icOOan3pTjNlF7K7EbHMhMlJwAXAc37w/s400/us32a.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The &lt;a href=&quot;http://udn.epicgames.com/Three/DevelopmentKitGemsPlatformerStarterKit.html&quot;&gt;Platformer Starter Kit&lt;/a&gt; uses a side view similar to the old 2D platform games. The &lt;i&gt;SPG_Camera&lt;/i&gt; and &lt;i&gt;SPG_CameraProperties&lt;/i&gt; classes are used to define the camera.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;SPG_CameraProperties&lt;/i&gt; class has only a &lt;i&gt;Vector&lt;/i&gt; used to define the position of the camera relative to the player. The class code is below:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_CameraProperties extends Object
      HideCategories(Object);

// How much to offset the camera by
var(CameraProperties) const Vector CameraOffset;

defaultproperties
{
}&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;An &lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/04/using-archetypes-in-unrealscript.html&quot;&gt;Archetype&lt;/a&gt; was created based on this class in the package &quot;StarterPlatformGameContent.Archetypes.CameraProperties&quot; as shown in the image below.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivyWoc4EwZ9l0WfAx972Z0aaqVwluh0DPAYJ0PIrEkkwLRysn0o7Vh-NFoXcZbwHoQmTbricNLcrEQH1EZ7cXf1l1sonFbQuF0KlugjfTZYhxIX895jq0Afx3gePPMMCAgw7_goD4L3Rk/s1600/us32b.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;135&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivyWoc4EwZ9l0WfAx972Z0aaqVwluh0DPAYJ0PIrEkkwLRysn0o7Vh-NFoXcZbwHoQmTbricNLcrEQH1EZ7cXf1l1sonFbQuF0KlugjfTZYhxIX895jq0Afx3gePPMMCAgw7_goD4L3Rk/s400/us32b.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The &lt;i&gt;SPG_Camera&lt;/i&gt; class has an instance of the &lt;i&gt;SPG_CameraProperties&lt;/i&gt; class that is loaded from the Archetype:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class SPG_Camera extends Camera;

var const archetype SPG_CameraProperties CameraProperties;

/**
 * Updates the camera&#39;s view target. Called once per tick
 *
 * @param    OutVT        Outputted camera view target
 * @param    DeltaTime    Time since the last tick was executed
 */
function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
    // Early exit if:
    // - We have a pending view target
    // - OutVT currently equals ViewTarget
    // - Blending parameter is lock out going
    if (PendingViewTarget.Target != None &amp;amp;&amp;amp; OutVT == ViewTarget &amp;amp;&amp;amp; BlendParams.bLockOutgoing)
    {
        return;
    }

    // Add the camera offset to the target&#39;s location to get the location of the camera
    OutVT.POV.Location = OutVT.Target.Location + CameraProperties.CameraOffset;
    // Make the camera point towards the target&#39;s location
    OutVT.POV.Rotation = Rotator(OutVT.Target.Location - OutVT.POV.Location);
}

defaultproperties
{
    CameraProperties=SPG_CameraProperties&#39;StarterPlatformGameContent.Archetypes.CameraProperties&#39;
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If you do not know anything about the Camera class, I recommend reading my article &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2012/01/camera-class-unrealscript.html&quot;&gt;Camera Class (UnrealScript)&lt;/a&gt;&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
The &lt;i&gt;SPG_Camera&lt;/i&gt; class modifies the camera in a very simple way, just overriding the &lt;i&gt;UpdateViewTarget()&lt;/i&gt; function of the &lt;i&gt;Camera&lt;/i&gt; class. This function receives as output parameter an variable of type &lt;i&gt;TViewTarget&lt;/i&gt;, which is a structure (&lt;i&gt;struct&lt;/i&gt;) defined in Camera class:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from Camera class...

/**
 * View Target definition
 * A View Target is responsible for providing the Camera with an ideal Point of View (POV)
 */
struct native TViewTarget
{
    /** Target Actor used to compute ideal POV */
    var()    Actor                   Target;

    /** Controller of Target (only for non Locally controlled Pawns) */
    var()    Controller              Controller;

    /** Point of View */
    var()    TPOV                    POV;

    /** Aspect ratio */
    var()    float                   AspectRatio;

    /** PlayerReplicationInfo (used to follow same player through pawn transitions, etc., when spectating) */
    var()    PlayerReplicationInfo   PRI;
};&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Within the structure &lt;i&gt;TViewTarget&lt;/i&gt; there is a variable called &lt;i&gt;POV&lt;/i&gt; that represents the Point of View. It&#39;s of type &lt;i&gt;TPOV&lt;/i&gt; which is a structure defined in &lt;i&gt;Object&lt;/i&gt; class:&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from Object class...

/**
 * Point Of View type.
 */
struct TPOV
{
    /** Location */
    var() Vector    Location;

    /** Rotation */
    var() Rotator    Rotation;

    /** FOV angle */
    var() float        FOV;

    structdefaultproperties
    {
        FOV=90.f
    }
};&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
Regarding the existing code in the &lt;i&gt;UpdateViewTarget()&lt;/i&gt; function of the &lt;i&gt;SPG_Camera&lt;/i&gt; class, the conditional test below was copied from the &lt;i&gt;UpdateViewTarget()&lt;/i&gt; function of the &lt;i&gt;Camera&lt;/i&gt; class and is used only to prevent the ViewTarget from being changed during an interpolation.&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;if (PendingViewTarget.Target != None &amp;amp;&amp;amp; OutVT == ViewTarget &amp;amp;&amp;amp; BlendParams.bLockOutgoing)&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The camera setup is done in the two lines of code below, which defines the position of the Point of View as the player&#39;s position added with the existing Vector in the SPG_CameraProperties class. After that, it is defined the rotation needed to point the camera toward the player.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;OutVT.POV.Location = OutVT.Target.Location + CameraProperties.CameraOffset;
OutVT.POV.Rotation = Rotator(OutVT.Target.Location - OutVT.POV.Location);&lt;/code&gt;&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/448306836936076879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/448306836936076879'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/06/platformer-kit-spgcamera-class.html' title='Platformer Kit: SPG_Camera class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7iNFMYQHQGyI7cptC-tlOMBWEHc1M9gGr-gg2ZKQat3L5_NWcN1aWa-y8dlfuPuVzIwbmUq7ItPvPKfTuA9A2VJ5x1vkJy-6DIyO_Ftbnex-icOOan3pTjNlF7K7EbHMhMlJwAXAc37w/s72-c/us32a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-5972452555818015427</id><published>2012-05-25T15:10:00.000-03:00</published><updated>2012-05-25T15:10:50.936-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Platformer Kit: SPG_HUD class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;We have seen&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;several concepts&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;related&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;to programming with&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;UnrealScript&lt;/span&gt;. &lt;span class=&quot;hps&quot;&gt;Now&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;it&#39;s time to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;see all these&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;concepts together&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;applied&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;in a game&lt;/span&gt;&lt;span class=&quot;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;&quot;&gt;In UDN (Unreal Developer Network) there is an excellent game example to study UnrealScript which is the &lt;i&gt;Platformer Starter Kit&lt;/i&gt;, available at:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;a href=&quot;http://udn.epicgames.com/Three/DevelopmentKitGemsPlatformerStarterKit.html&quot;&gt;http://udn.epicgames.com/Three/DevelopmentKitGemsPlatformerStarterKit.html&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
This page at UDN has all the necessary guidelines to configure and run the Kit in UDK.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The UnrealScript source code of the Platformer Starter Kit is very well commented. Even so, some parts of the code is very complex for Beginners in UnrealScript. I&#39;ll start a series of articles analyzing the existing UnrealScript classes in the Platformer Starter Kit with the goal of generating an additional material to help in understanding the logic of this example of a functional game.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
Let&#39;s start by looking at the simplest class: &lt;b&gt;SPG_HUD&lt;/b&gt;. The only goal of this class is to draw on the bottom left of the screen the text &quot;&lt;i&gt;Health&lt;/i&gt;&quot; with the numeric value that represents the current health of the player as in the image below.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSvNx8NpSvbW7xWIWI9O0FDZWoy6a2-c68Mz93FO9wZ9V-RALWn17Qidhk75K9T-ZWfA1wgPMOW8r8RE58GPCUCNyApxwaFc833I1G_B7O3xq9gFKgB_VTA5w6xmD2pkofagbyoeHXuA/s1600/us31a.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSvNx8NpSvbW7xWIWI9O0FDZWoy6a2-c68Mz93FO9wZ9V-RALWn17Qidhk75K9T-ZWfA1wgPMOW8r8RE58GPCUCNyApxwaFc833I1G_B7O3xq9gFKgB_VTA5w6xmD2pkofagbyoeHXuA/s1600/us31a.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;If you do not know anything about the HUD class, I recommend reading my article &quot;&lt;a href=&quot;http://romerounrealscript.blogspot.com.br/2011/11/drawing-hud-unrealscript.html&quot;&gt;Drawing the HUD&lt;/a&gt;&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The SPG_HUD class has only the &lt;i&gt;PostRender()&lt;/i&gt; function containing the following code.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;event PostRender()
{
    local float XL, YL;
    local String Text;

    Super.PostRender();

    // Ensure that PlayerOwner and PlayerOwner.Pawn are valid
    if (PlayerOwner != None &amp;amp;&amp;amp; PlayerOwner.Pawn != None)
    {
        // Set the text to say Health: and the numerical value of the player pawn&#39;s health
        Text = &quot;Health: &quot; $ PlayerOwner.Pawn.Health;
        // Set the font
        Canvas.Font = class&#39;Engine&#39;.static.GetMediumFont();
        // Set the current drawing color
        Canvas.SetDrawColor(255, 255, 255);
        // Get the dimensions of the text in the font assigned
        Canvas.StrLen(Text, XL, YL);
        // Set the current drawing position to the be at the bottom left position with a padding of 4 pixels
        Canvas.SetPos(4, Canvas.ClipY - YL - 4);
        // Draw the text onto the screen
        Canvas.DrawText(Text);
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The comments below are related to existing concepts in the above code.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
There are two main functions in the HUD class used to draw on the screen, which are &quot;&lt;i&gt;DrawHud()&lt;/i&gt;&quot; and &quot;&lt;i&gt;PostRender()&lt;/i&gt;&quot;. The &quot;&lt;i&gt;DrawHud()&lt;/i&gt;&quot; is only called if the variable &lt;i&gt;bShowHud&lt;/i&gt; is equal to true and if the Score Table is not visible (&lt;i&gt;bShowScores&lt;/i&gt; equal to false). To understand the relationship between the functions &quot;&lt;i&gt;DrawHud()&lt;/i&gt;&quot; and &quot;&lt;i&gt;PostRender()&lt;/i&gt;&quot;, analyze the function &quot;&lt;i&gt;PostRender()&lt;/i&gt;&quot; of the HUD class (Engine package).&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The &lt;i&gt;PlayerOwner&lt;/i&gt; variable is declared in the HUD class and represents the &lt;i&gt;PlayerController&lt;/i&gt; responsible for the HUD. Its initialization is done in the function &quot;&lt;i&gt;PostBeginPlay()&lt;/i&gt;&quot; of the HUD class. &lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The concatenation of strings can be done using two operators: &lt;b&gt;$&lt;/b&gt; and &lt;b&gt;@&lt;/b&gt;. The only difference between them is that the &lt;b&gt;@&lt;/b&gt; operator puts a space between the strings. Numerical values ​​used in the concatenation are automatically converted to strings. Another way to concatenate strings is using the operators &lt;b&gt;$=&lt;/b&gt; and &lt;b&gt;@=&lt;/b&gt; that appends a string to an existing string variable. For example, to complement the text of the HUD with the information &lt;i&gt;HealthMax&lt;/i&gt;, we can do so:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;Text = &quot;Health: &quot; $ PlayerOwner.Pawn.Health;
Text @= &quot;- HealthMax:&quot; @ PlayerOwner.Pawn.HealthMax;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The font used to write the text is obtained from a static function in the &lt;i&gt;Engine&lt;/i&gt; class. There are four pre-defined sizes of fonts that are obtained through the functions:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;native static final function Font GetTinyFont();
native static final function Font GetSmallFont();
native static final function Font GetMediumFont();
native static final function Font GetLargeFont();&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;
The definition of the font color is done by the &lt;i&gt;SetDrawColor()&lt;/i&gt; function of the Canvas class. The color is represented in RGB format, where each parameter is one byte (0-255). It can also be defined the Alpha element of the color that represents its opacity. There is also the &lt;i&gt;SetDrawColorStruct()&lt;/i&gt; function which receives a struct of type &lt;i&gt;color&lt;/i&gt;. Below are the two functions:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;native final function SetDrawColor(byte R, byte G, byte B, optional byte A = 255);

/** Set the draw color using a color struct */
final function SetDrawColorStruct(color C)
{
    SetDrawColor(C.R, C.G, C.B, C.A);
}&lt;/code&gt;&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/5972452555818015427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/5972452555818015427'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/05/platformer-kit-spghud-class.html' title='Platformer Kit: SPG_HUD class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuSvNx8NpSvbW7xWIWI9O0FDZWoy6a2-c68Mz93FO9wZ9V-RALWn17Qidhk75K9T-ZWfA1wgPMOW8r8RE58GPCUCNyApxwaFc833I1G_B7O3xq9gFKgB_VTA5w6xmD2pkofagbyoeHXuA/s72-c/us31a.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-8872342518374628885</id><published>2012-04-28T18:39:00.000-03:00</published><updated>2012-04-28T18:40:50.816-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Using Archetypes in UnrealScript</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
The use of archetypes allows us to store an instance of a class to be modified and used as a template to create other instances of that class in the level editor. This feature is very handy for Designers who want to modify Actors in the level without relying entirely on the programmer.&lt;br /&gt;
&lt;br /&gt;
Create an Archetype is simple, just select an Actor of the level, right-click and choose &quot;Create Archetype ...&quot;, as seen in the image below:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHY-zkXRw85ipdNjWvvYwXl3IsXdqOY-KZH98SxzkiukjHAldLRioMT9U-O1m3XRKcWGZv3mM4AtODH1B7zD7Ze3QGTjwuEDekmsunLF4GDv5PSdxQB3s4q8S9PxZgr12xN-pmEurTPA/s1600/us30a.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHY-zkXRw85ipdNjWvvYwXl3IsXdqOY-KZH98SxzkiukjHAldLRioMT9U-O1m3XRKcWGZv3mM4AtODH1B7zD7Ze3QGTjwuEDekmsunLF4GDv5PSdxQB3s4q8S9PxZgr12xN-pmEurTPA/s400/us30a.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Another way to create an archetype is through the window &quot;Actor Classes&quot;. Select a class and right-click to see the option &quot;Create Archetype...&quot;.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrQYcZ8O3YLd3L5w4RwgsTGGOHOkFGJwcklFdk1a2iEQs8UD6VnIjwgL26OMonPCDkDXU8yvfD2vmwPumh0PHYntMkI93ryZ4Atrj6cc_vRRP9SiNmpg2UBRLTSonNmFEE4XO6lvduM7s/s1600/us30b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;202&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrQYcZ8O3YLd3L5w4RwgsTGGOHOkFGJwcklFdk1a2iEQs8UD6VnIjwgL26OMonPCDkDXU8yvfD2vmwPumh0PHYntMkI93ryZ4Atrj6cc_vRRP9SiNmpg2UBRLTSonNmFEE4XO6lvduM7s/s400/us30b.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;After that, a dialog box is displayed where you should enter the name of the new archetype and the package where it will be stored. The &quot;Grouping&quot; is optional.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbDnfJ8WMiLh5YE0FndJteosL6AyfnwpcXj2cg3toZvy74VXy5fPpXXWvJw4kDmcQdfYnP9jxnKUGwuu1UoTKeQm7o009B_CncE6bK9-fALGodyKIyY_O1WhADdI1ImVzUyP6HKYSOJWM/s1600/us30c.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbDnfJ8WMiLh5YE0FndJteosL6AyfnwpcXj2cg3toZvy74VXy5fPpXXWvJw4kDmcQdfYnP9jxnKUGwuu1UoTKeQm7o009B_CncE6bK9-fALGodyKIyY_O1WhADdI1ImVzUyP6HKYSOJWM/s1600/us30c.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;
After creation, the new archetype will be displayed in the &quot;Content Browser&quot;. You can change its properties by clicking the right button on the Archetype and choosing &quot;Properties...&quot;. To get the full name of the Archetype choose &quot;Copy Full Name to Clipboard&quot; and then paste in the desired place.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlpYDGuyd6SbLCteUItiJKuufddzhK_ehdKdS-d2ovFZOUAhwJpXSrYJ1ej9WaN3Kg7wZhWa0cqAeBS84U9EFNnhu8xLXxPzXVmSb9hoq95Ycl1a6IUiH3aCYWLg-0-Sl4IxV6lo-vmUY/s1600/us30d.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;144&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlpYDGuyd6SbLCteUItiJKuufddzhK_ehdKdS-d2ovFZOUAhwJpXSrYJ1ej9WaN3Kg7wZhWa0cqAeBS84U9EFNnhu8xLXxPzXVmSb9hoq95Ycl1a6IUiH3aCYWLg-0-Sl4IxV6lo-vmUY/s400/us30d.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;
&lt;br /&gt;
I created a class called &lt;i&gt;ArchetypeSpawner &lt;/i&gt;to illustrate the use of archetypes in UnrealScript. This class is &lt;i&gt;placeable&lt;/i&gt; and has a variable named &lt;i&gt;archetypeReference &lt;/i&gt;which is used to refer to an archetype. There is a function that can be called by other classes to create an instance based on the archetype referenced. In this example it was created a 5-second Timer that will call this function once. The great advantage of this example using archetypes is that the variable is displayed in the editor for the Designer, so he can create any Archetype and inform the full name in the variable archetypeReference in the properties window, as seen in the image and code below.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-3TLRbUQWzZiElYPKfJs1ZtP1FfSXK9ioSr6gttzT6igNfYL6eSvZhshmKolU0QMT2dg5hNRoy_fW0WBXCTCY8PmB3_ix6K3XRGaipvl62Wg1PvGRcpP-7dxx4_GeavtEJKcNaKLzuLE/s1600/us30e.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;185&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-3TLRbUQWzZiElYPKfJs1ZtP1FfSXK9ioSr6gttzT6igNfYL6eSvZhshmKolU0QMT2dg5hNRoy_fW0WBXCTCY8PmB3_ix6K3XRGaipvl62Wg1PvGRcpP-7dxx4_GeavtEJKcNaKLzuLE/s400/us30e.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class ArchetypeSpawner extends Actor
      placeable;

var() const archetype Actor archetypeReference;
//The use of the archetype modifier is optional.
      
event simulated PostBeginPlay()
{
    SetTimer(5);    
}

function Timer()
{
    SpawnArchetypeAt( self.Location );
}    

function Actor SpawnArchetypeAt( vector startLocation ) 
{    
    local Actor archetypeSpawned;
    
    archetypeSpawned = Spawn(archetypeReference.Class, , , startLocation, , archetypeReference);
    
    return archetypeSpawned;
}      

defaultproperties
{    
    archetypeReference=UltraHealthPack&#39;ArchetypeExample.HealthPackArchetype&#39;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
For more information about Archetypes:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;
&lt;a href=&quot;http://udn.epicgames.com/Three/ArchetypesTechnicalGuide.html&quot;&gt;Archetypes Technical Guide&lt;/a&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8872342518374628885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8872342518374628885'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/04/using-archetypes-in-unrealscript.html' title='Using Archetypes in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZHY-zkXRw85ipdNjWvvYwXl3IsXdqOY-KZH98SxzkiukjHAldLRioMT9U-O1m3XRKcWGZv3mM4AtODH1B7zD7Ze3QGTjwuEDekmsunLF4GDv5PSdxQB3s4q8S9PxZgr12xN-pmEurTPA/s72-c/us30a.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-1767829397246564382</id><published>2012-04-09T22:16:00.001-03:00</published><updated>2012-04-10T11:20:59.287-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>AI Navigation in UnrealScript</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Moving in a level is a fundamental aspect of Artificial Intelligence in games. The most common form of AI navigation is based on &lt;i&gt;waypoints&lt;/i&gt; that are placed on the level to create a network of paths. The UDK also supports a more efficient navigation system based on &quot;&lt;i&gt;Navigation Mesh&lt;/i&gt;&quot; which results in a more natural movement.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Waypoints are represented by the class PathNode:&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSrB7MPSsBeXYu4FFcdcKYhv7Zxori5YoGzIhLDWA6QVMEN-FH__CmpsRr-u7UGrJH1VuAfHUtv0mGsd6NwIZW4TP2wxHkqISKHgY_ygxHDGM16jYIYiggkCC1eRgITuS3iYtCZjeMLd4/s1600/us29a.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSrB7MPSsBeXYu4FFcdcKYhv7Zxori5YoGzIhLDWA6QVMEN-FH__CmpsRr-u7UGrJH1VuAfHUtv0mGsd6NwIZW4TP2wxHkqISKHgY_ygxHDGM16jYIYiggkCC1eRgITuS3iYtCZjeMLd4/s1600/us29a.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the AIController class we have a code example that uses the waypoints system:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from AIController class (Engine package)

state ScriptedMove
{
    // state functions...
    
    Begin:
    // while we have a valid pawn and move target, and
    // we haven&#39;t reached the target yet
    while (Pawn != None &amp;amp;&amp;amp;
           ScriptedMoveTarget != None &amp;amp;&amp;amp;
           !Pawn.ReachedDestination(ScriptedMoveTarget))
    {
        // check to see if it is directly reachable
        if (ActorReachable(ScriptedMoveTarget))
        {
            // then move directly to the actor
            MoveToward(ScriptedMoveTarget, ScriptedFocus);
        }
        else
        {
           // attempt to find a path to the target
           MoveTarget = FindPathToward(ScriptedMoveTarget);
           if (MoveTarget != None)
           {
               // move to the first node on the path
               MoveToward(MoveTarget, ScriptedFocus);
           }
           else
           {
               // abort the move                
               ScriptedMoveTarget = None;
           }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the system based on &quot;&lt;i&gt;Navigation Mesh&lt;/i&gt;&quot;, the path is represented by a set of convex polygons that are generated automatically in the level from an actor known as Pylon:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4YkfOxysC5vJIrtRyjL04Ex__S8Jggtwxy9vWzOR7cTJbk5OyMKiwMhINl_QgOG6pJ3iVqleeGP7e6_FKEsK42i1d0dqyIsfWzzK3NA2NZnlyg8SuXOVCcic8INk-7EdkB4q_TcWh6v0/s1600/us29b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4YkfOxysC5vJIrtRyjL04Ex__S8Jggtwxy9vWzOR7cTJbk5OyMKiwMhINl_QgOG6pJ3iVqleeGP7e6_FKEsK42i1d0dqyIsfWzzK3NA2NZnlyg8SuXOVCcic8INk-7EdkB4q_TcWh6v0/s1600/us29b.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The functions related to pathfinding using &quot;&lt;i&gt;Navigation Mesh&lt;/i&gt;&quot; are contained in a class called &lt;b&gt;NavigationHandle&lt;/b&gt;. This class works with the concept of &lt;b&gt;Path Constraints&lt;/b&gt; and &lt;b&gt;Goal Evaluators&lt;/b&gt;. The use of Path Constraints allows to set criteria to be taken into account during the pathfinding. The simplest Path Constraint is the &lt;i&gt;NavMeshPath_Toward&lt;/i&gt;. The Goal Evaluator is used to define the end of pathfinding. The most common Goal Evaluator is the &lt;i&gt;NavMeshGoal_At&lt;/i&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Looking in the source code that came with the UDK, I found a simple example of pathfinding using &quot;&lt;i&gt;Navigation Mesh&lt;/i&gt;&quot;. The code below is from the function &lt;i&gt;GeneratePathToActor()&lt;/i&gt; of the &lt;i&gt;GameCrowdAgent&lt;/i&gt; class:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from GameCrowdAgent class (GameFramework package)

/**
  * Generate a path to Goal on behalf of the QueryingAgent
  */
event vector GeneratePathToActor( Actor Goal, optional float WithinDistance, optional bool bAllowPartialPath )
{
    local vector NextDest;

    LastPathingAttempt = WorldInfo.TimeSeconds;
    NextDest = Goal.Location;

    // make sure we have a valid navigation handle
    if ( NavigationHandle == None )
    {
        InitNavigationHandle();
    }
    if( (NavigationHandle != None) &amp;amp;&amp;amp; !NavigationHandle.ActorReachable(Goal) )
    {
        class&#39;NavMeshPath_Toward&#39;.static.TowardGoal( NavigationHandle, Goal );
        class&#39;NavMeshGoal_At&#39;.static.AtActor( NavigationHandle, Goal, WithinDistance, bAllowPartialPath );

        if ( NavigationHandle.FindPath() )
        {
            NavigationHandle.GetNextMoveLocation(NextDest, SearchExtent.X);
        }
        NavigationHandle.ClearConstraints();
    }

    return NextDest;
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;For more information about AI Navigation:&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;a href=&quot;http://udn.epicgames.com/Three/AIAndNavigationHome.html&quot;&gt;AI &amp;amp; Navigation&lt;/a&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1767829397246564382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1767829397246564382'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/04/ai-navigation-in-unrealscript.html' title='AI Navigation in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSrB7MPSsBeXYu4FFcdcKYhv7Zxori5YoGzIhLDWA6QVMEN-FH__CmpsRr-u7UGrJH1VuAfHUtv0mGsd6NwIZW4TP2wxHkqISKHgY_ygxHDGM16jYIYiggkCC1eRgITuS3iYtCZjeMLd4/s72-c/us29a.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-7324029223972884588</id><published>2012-03-17T10:02:00.000-03:00</published><updated>2012-03-17T10:02:35.174-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Using Configuration Files in UnrealScript</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Configuration files are files in plain text format with the extension &quot;.ini&quot; with informations that will be used by the game.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the folder &quot;&lt;i&gt;..\UDK-20??-??\UDKGame\Config&lt;/i&gt;&quot; you will find various configuration files used by the UDK. As an example, the file &quot;DefaultInput.ini&quot; that is used for key binds.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The main advantage in using configuration files is to allow the setting of a game without having to recompile the source code. Thus a &lt;i&gt;Game Designer&lt;/i&gt; can make the adjustments of the data of a game without relying on a programmer.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;To use a configuration file in a class, add the modifier &lt;b&gt;config&lt;/b&gt; as follows:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class ClassName extends SuperClass config(ConfigName); 
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To identify what are the variables that will get their values from the configuration files, also use the &lt;b&gt;config&lt;/b&gt; modifier when declaring the variables:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;var config int exampleVar;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The next step is to create in the folder &quot;&lt;i&gt;..\UDK-20??-??\UDKGame\Config&lt;/i&gt;&quot; a configuration file named &quot;&lt;i&gt;DefaultConfigName.ini&lt;/i&gt;&quot; containing the values to be stored in variables. When the game runs it will look for a file called &quot;&lt;i&gt;UDKConfigName.ini&lt;/i&gt;&quot;. If this file is not found, the game will look for &quot;DefaultConfigName.ini&quot; in order to create the &quot;UDKConfigName.ini&quot; with default values. You should not edit the file &quot;UDK&lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;ConfigName&lt;/span&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;.ini&quot; because at some time it may be overwritten and you will lose your changes.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;We can use the function &quot;&lt;b&gt;SaveConfig()&lt;/b&gt;&quot; to save in the file &quot;UDKConfigName.ini&quot; new values of configuration variables that were modified during the execution of the game. There is another function called &quot;&lt;b&gt;StaticSaveConfig()&lt;/b&gt;&quot; which allows the default values to be restored. This is a common option in the settings screen of games, as can be seen in the image below.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEispFP_PoimLCAL57DZLzuAz0KIHkMPf3kPIf797c9BdJBBAZ9yiuLQJhWOFWYEHvopsFcthNCuUo7HYLJinDYxX1rKYgKtEdek53xOVizB2KhAXdHhmEaaMc1qLfBc-Hkwz0BXFXSBO8M/s1600/us28a.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;67&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEispFP_PoimLCAL57DZLzuAz0KIHkMPf3kPIf797c9BdJBBAZ9yiuLQJhWOFWYEHvopsFcthNCuUo7HYLJinDYxX1rKYgKtEdek53xOVizB2KhAXdHhmEaaMc1qLfBc-Hkwz0BXFXSBO8M/s400/us28a.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The function &quot;&lt;b&gt;StaticSaveConfig()&lt;/b&gt;&quot; is static, that means it does not need an object to be executed. The static functions are like class functions, to run it just use the class name plus the word &lt;i&gt;static&lt;/i&gt; as in this example:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class&#39;ClassName&#39;.static.StaticSaveConfig();
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;As an example, I made a class that draws on the screen some information that was obtained in a configuration file, as can be seen in the image below.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcKgr7zSjZS0AF1aDOO0qdeVgnqxSgTEaQe80sTuy6rnbYAXCdC8M5HGbwUf-qPGDpZk3UsztdC7GDWC9DPltZmgWXs2PICFFL0djqXwIvY4j8DB5VEPWF2lfZH2qu7wc4_OoBscV6v64/s1600/us28b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;117&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcKgr7zSjZS0AF1aDOO0qdeVgnqxSgTEaQe80sTuy6rnbYAXCdC8M5HGbwUf-qPGDpZk3UsztdC7GDWC9DPltZmgWXs2PICFFL0djqXwIvY4j8DB5VEPWF2lfZH2qu7wc4_OoBscV6v64/s400/us28b.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;I created a configuration file called &quot;DefaultWarrior.ini&quot; containing the following information:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;[RomeroScripts.CyberWarrior]
codename=DeadLocker
age=33

implants=Bionic Eye
implants=Night Vision
implants=Thermal Resistence

Attributes=(strength=12, agility=10, baseExperience=5000, currentExperience=6000)
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The first line shows what is the class that will use this file. &quot;RomeroScripts&quot; is the name of the package that I use and &quot;CyberWarrior&quot; is the name of the class.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The class &quot;CyberWarrior&quot; defines the configuration variables. Then it uses a Timer of 1 second to increase the Current Experience and uses another Timer of 10 seconds to save the data of the player. The function &quot;DrawHUD()&quot; draws the informations on the screen.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class CyberWarrior extends SimplePawn
      config(Warrior);

var config string codename;      
var config int age;

var config Array&amp;lt;string&amp;gt;    implants;

struct stAttributes
{
    var int strength, agility, baseExperience, currentExperience;
};

var config stAttributes Attributes;

event simulated PostBeginPlay()
{
    SetTimer(1, true);
    SetTimer(10, true, &#39;SaveWarrior&#39;);
}
function Timer()
{
    Attributes.currentExperience++;    
}
function SaveWarrior()
{
    SaveConfig();
}

simulated function DrawHUD( HUD H )
{
    local int i;
    
    super.DrawHUD(H);
    
    H.Canvas.SetDrawColor(255, 255, 255); // White   
    
    H.Canvas.SetPos(50, 10);   
    H.Canvas.DrawText(&quot;Codename:&quot; @ codename @ &quot;- Age:&quot; @ age) ;
    
    H.Canvas.SetPos(50, 40);
    H.Canvas.DrawText( &quot;*** Attributes ***&quot; );
    H.Canvas.SetPos(50, 55);
    H.Canvas.DrawText( &quot;Strength :&quot; @ Attributes.strength);
    H.Canvas.SetPos(50, 70);
    H.Canvas.DrawText( &quot;Agility :&quot; @ Attributes.agility);
    H.Canvas.SetPos(50, 85);
    H.Canvas.DrawText( &quot;Base Experience :&quot; @ Attributes.baseExperience);
    H.Canvas.SetPos(50, 100);
    H.Canvas.DrawText( &quot;Current Experience :&quot; @ Attributes.currentExperience);
    
    H.Canvas.SetPos(300, 40);
    H.Canvas.DrawText( &quot;*** Implants ***&quot;);
    for( i =0; i &amp;lt; implants.Length; i++)
    {
       H.Canvas.SetPos(300, 55 + i * 15);       
       H.Canvas.DrawText( implants[i] );
    }    
} 
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To use this class we need to create the new &lt;i&gt;GameInfo&lt;/i&gt; that will reference the class CyberWarrior:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class GameWarrior extends SimpleGame;

defaultproperties
{        
    DefaultPawnClass=class&#39;RomeroScripts.CyberWarrior&#39;    
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;I&#39;m using as the base class &quot;SimpleGame&quot; because it is easier to write on the screen in &quot;SimpleGame&quot; than using the &quot;UTGame&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;When running the game you will see that the information &quot;Current Experience&quot; is changed every second. Wait at least 10 seconds before leaving the game to be saved the current state of the class. When you exit the game, look for the file &quot;UDKWarrior.ini&quot; in the configuration folder. You&#39;ll see that &quot;currentExperience&quot;, which is within the &quot;Attributes&quot;, was modified. Also appear in this file other configuration variables that belong to the superclass &quot;SimplePawn&quot;.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;For more information:&lt;/div&gt;&lt;a href=&quot;http://udn.epicgames.com/Three/ConfigurationFiles.html&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Configuration files&lt;/span&gt;&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/7324029223972884588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/7324029223972884588'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/03/using-configuration-files-in.html' title='Using Configuration Files in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEispFP_PoimLCAL57DZLzuAz0KIHkMPf3kPIf797c9BdJBBAZ9yiuLQJhWOFWYEHvopsFcthNCuUo7HYLJinDYxX1rKYgKtEdek53xOVizB2KhAXdHhmEaaMc1qLfBc-Hkwz0BXFXSBO8M/s72-c/us28a.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-5661579517952752788</id><published>2012-03-06T19:07:00.002-03:00</published><updated>2012-03-09T09:33:13.325-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Vehicle Class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The Vehicle class is a subclass of &lt;a href=&quot;http://romerounrealscript.blogspot.com/2011/10/pawn-class-unrealscript.html&quot;&gt;Pawn&lt;/a&gt;. The vehicle system in the UDK is quite complex and allows the creation of different types of vehicles. The image below shows the subclasses of the Vehicle class in the UDK:&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi20g4YMrqhaNB_MDszqioy5aOM0zRtzHnDRRfwfyUccxz3btYI1UBdeaXmJBL_0r2ltbeTJ0d27HKXCmV-0G_SccDeOyPhXudxuffJfy45HHu8ooy8pf1Ehg5VTm6p5YCCI9SbxJLTN7E/s1600/us27a.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi20g4YMrqhaNB_MDszqioy5aOM0zRtzHnDRRfwfyUccxz3btYI1UBdeaXmJBL_0r2ltbeTJ0d27HKXCmV-0G_SccDeOyPhXudxuffJfy45HHu8ooy8pf1Ehg5VTm6p5YCCI9SbxJLTN7E/s1600/us27a.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;We can see four types of vehicles defined that are: UTVehicle_Cicada, UTVehicle_Hoverboard, UTVehicle_Manta and UTVehicle_Scorpion. However, all of these classes have the &lt;b&gt;abstract&lt;/b&gt; modifier. This indicates that objects of these classes cannot be created. The main idea of abstract classes is to create a base class with several features to serve as a model. The classes that really define the vehicles are those that end with the name &quot;&lt;i&gt;_Content&lt;/i&gt;&quot;&lt;/span&gt;.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;To place vehicles in the level you have to use the UDKVehicleFactory class which is a subclass of &quot;&lt;i&gt;Actor-&amp;gt;NavigationPoint&lt;/i&gt;&quot;. The image below shows the existing types in UDK:&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghuuxGpuNGC4Zx2eOlJA3Jq2wrvJ3fbntklsJPzy-9pcrOkZv7bJUoDq4ETDC1VFzJREkAsV70SNKMXhtKIzM73E9Vx9wEeE_t2OZ9571ezey3bjE7eNHBdSXOB8kkuXsP71gVBe20tqU/s1600/us27b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghuuxGpuNGC4Zx2eOlJA3Jq2wrvJ3fbntklsJPzy-9pcrOkZv7bJUoDq4ETDC1VFzJREkAsV70SNKMXhtKIzM73E9Vx9wEeE_t2OZ9571ezey3bjE7eNHBdSXOB8kkuXsP71gVBe20tqU/s1600/us27b.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;There are only three &lt;i&gt;Factory&lt;/i&gt;. The vehicle that is missing is the Hoverboard because it is already available to the player in the game type &quot;&lt;i&gt;Vehicle Capture The Flag&lt;/i&gt;&quot;. To test it in the editor set the &lt;i&gt;Game Type&lt;/i&gt; to &lt;i&gt;UTVehicleCTFGame_Content&lt;/i&gt; and after starting the game press the &quot;Q&quot; key to use the Hoverboard that is a sort of skateboard without wheels as seen in the image below.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOJVu80aRVibR6aHFnSjlyWUz3OxR04b_yBCWsX5lESpiLUaRwIinB6bH7PR0t33BsO2OKplK-WWNPxlJvS6y-ut0aM85w8iT2kUqbsJ5kvofZbPWZ_0RhAMdtuyhYCD-6O12aaEZF-MI/s1600/us27c.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;221&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOJVu80aRVibR6aHFnSjlyWUz3OxR04b_yBCWsX5lESpiLUaRwIinB6bH7PR0t33BsO2OKplK-WWNPxlJvS6y-ut0aM85w8iT2kUqbsJ5kvofZbPWZ_0RhAMdtuyhYCD-6O12aaEZF-MI/s400/us27c.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To enter a vehicle that is available on the level, go near it and press the &quot;E&quot; key. If you can enter the vehicle, one of the functions of the Vehicle class that will be called is &quot;&lt;i&gt;DriverEnter(Pawn P)&lt;/i&gt;&quot; whose code is below.&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from Vehicle class (Engine package)

/** DriverEnter()
 * Make Pawn P the new driver of this vehicle
 * Changes controller ownership across pawns
 */
function bool DriverEnter(Pawn P)
{
    local Controller C;

    // Set pawns current controller to control the vehicle pawn instead
    C = P.Controller;
    Driver = P;
    Driver.StartDriving( self );
    if ( Driver.Health &amp;lt;= 0 )
    {
        Driver = None;
        return false;
    }
    SetDriving(true);

    // Disconnect PlayerController from Driver and connect to Vehicle.
    C.Unpossess();
    Driver.SetOwner( Self ); // This keeps the driver relevant.
    C.Possess( Self, true );

    if( PlayerController(C) != None &amp;amp;&amp;amp; !C.IsChildState(C.GetStateName(), LandMovementState) )
    {
        PlayerController(C).GotoState( LandMovementState );
    }

    WorldInfo.Game.DriverEnteredVehicle(self, P);
    return true;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;This function takes the object reference of the Pawn who entered the vehicle and keep in the variable &lt;i&gt;Driver&lt;/i&gt; so it can be restored when leaves the vehicle. The Controller stops to reference the Pawn through the function &quot;&lt;i&gt;Unpossess()&lt;/i&gt;&quot; and will now reference the vehicle through the function &quot;&lt;i&gt;Possess (Self, true)&lt;/i&gt;&quot;. The &lt;b&gt;Self&lt;/b&gt; object is the reference to the vehicle and the second parameter with the value &quot;&lt;i&gt;true&lt;/i&gt;&quot; indicates that it is a transition to a vehicle. A test is done to verify if the Controller is a PlayerController and if it is not in the state &lt;i&gt;LandMovementState&lt;/i&gt;. &lt;i&gt;LandMovementState&lt;/i&gt; is a variable of type &lt;b&gt;name&lt;/b&gt; that was defined in the Pawn class. This type of variable is used to store the name of an item in UnrealScript such as names of classes, functions and states. In the Pawn class it receives the value &lt;i&gt;PlayerWalking&lt;/i&gt; in the DefaultProperties. In the Vehicle class this variable receives the value &lt;i&gt;PlayerDriving&lt;/i&gt;. This means that when entering a vehicle the PlayerController go to the state &lt;i&gt;PlayerDriving&lt;/i&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the PlayerController we can see a good example of the use of states. Each Tick the &quot;PlayerMove()&quot; function is called, if the state is &lt;i&gt;PlayerWalking&lt;/i&gt; then the &quot;PlayerMove()&quot; function will call the &quot;ProcessMove()&quot; function, but if the state is &lt;i&gt;PlayerDriving&lt;/i&gt; then the &quot;PlayerMove()&quot; function will call &quot;ProcessDrive()&quot;. The code below shows the functions defined for the state &lt;i&gt;PlayerDriving&lt;/i&gt; in the PlayerController class.&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from PlayerController classe (Engine package)

// Player Driving a vehicle.
state PlayerDriving
{
ignores SeePlayer, HearNoise, Bump;

    function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot);

    // Set the throttle, steering etc. for the vehicle based on the input provided
    function ProcessDrive(float InForward, float InStrafe, float InUp, bool InJump)
    {
        local Vehicle CurrentVehicle;

        CurrentVehicle = Vehicle(Pawn);
        if (CurrentVehicle != None)
        {            
            bPressedJump = InJump;
            CurrentVehicle.SetInputs(InForward, -InStrafe, InUp);
            CheckJumpOrDuck();
        }
    }

    function PlayerMove( float DeltaTime )
    {        
        UpdateRotation(DeltaTime);
      
        ProcessDrive(PlayerInput.RawJoyUp, PlayerInput.RawJoyRight, PlayerInput.aUp, bPressedJump);
        if (Role &amp;lt; ROLE_Authority)
        {
            ServerDrive(PlayerInput.RawJoyUp, PlayerInput.RawJoyRight, PlayerInput.aUp, bPressedJump, 
                        ((Rotation.Yaw &amp;amp; 65535) &amp;lt;&amp;lt; 16) + (Rotation.Pitch &amp;amp; 65535));
        }

        bPressedJump = false;
    }

    unreliable server function ServerUse()
    {
        local Vehicle CurrentVehicle;

        CurrentVehicle = Vehicle(Pawn);
        CurrentVehicle.DriverLeave(false);
    }

    event BeginState(Name PreviousStateName)
    {
        CleanOutSavedMoves();
    }

    event EndState(Name NextStateName)
    {
        CleanOutSavedMoves();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;For more information about the Vehicle class: &lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif;&quot;&gt;&lt;a href=&quot;http://udn.epicgames.com/Three/VehiclesTechnicalGuide.html&quot;&gt;Vehicle System Technical Guide&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMEW8mo5wNMBdwfqHx2xUnRSnwD73x7CbFjFpseQrsTnilQVIP8ckalgC2zP3LgXB1jLNMLcNrky9hHxhC39cs9M7SSuVU738PhN4jUkeR1IGCyZA5cjrbIP5AGf0IQZRC177IodfFLZA/s1600/us27d.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMEW8mo5wNMBdwfqHx2xUnRSnwD73x7CbFjFpseQrsTnilQVIP8ckalgC2zP3LgXB1jLNMLcNrky9hHxhC39cs9M7SSuVU738PhN4jUkeR1IGCyZA5cjrbIP5AGf0IQZRC177IodfFLZA/s400/us27d.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/5661579517952752788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/5661579517952752788'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/03/vehicle-class-unrealscript.html' title='Vehicle Class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi20g4YMrqhaNB_MDszqioy5aOM0zRtzHnDRRfwfyUccxz3btYI1UBdeaXmJBL_0r2ltbeTJ0d27HKXCmV-0G_SccDeOyPhXudxuffJfy45HHu8ooy8pf1Ehg5VTm6p5YCCI9SbxJLTN7E/s72-c/us27a.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-3731217889524562461</id><published>2012-02-27T21:46:00.002-03:00</published><updated>2012-02-29T09:03:08.995-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Using Physics in UnrealScript</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The code below shows an enumeration in the Actor class that indicates the possible types of physics that an Actor can use.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;//Extract from Actor class

var(Movement) const enum EPhysics
{
    PHYS_None,
    PHYS_Walking,
    PHYS_Falling,
    PHYS_Swimming,
    PHYS_Flying,
    PHYS_Rotating,
    PHYS_Projectile,
    PHYS_Interpolating,
    PHYS_Spider,
    PHYS_Ladder,
    PHYS_RigidBody,
    PHYS_SoftBody, 
    PHYS_NavMeshWalking, 
    PHYS_Unused,
    PHYS_Custom,    
} Physics;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;I didn&#39;t find any official reference about the meaning of each of these types. To define the physic type of an Actor use the function &lt;i&gt;SetPhysics()&lt;/i&gt; passing as parameter one of the enumeration values, as in the example below:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;SetPhysics(PHYS_Projectile);
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To initialize the physics of a Pawn use the function &lt;i&gt;SetMovementPhysics()&lt;/i&gt; that has the following code:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from Pawn class

function SetMovementPhysics()
{
    // check for water volume
    if (PhysicsVolume.bWaterVolume)
    {
        SetPhysics(PHYS_Swimming);
    }
    else if (Physics != PHYS_Falling)
    {
        SetPhysics(PHYS_Falling);
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;When an object of the Pawn class is with the physics type &lt;i&gt;PHYS_Falling&lt;/i&gt; he is affected by gravity and will fall until touch a ground when turns to &lt;i&gt;PHYS_Walking&lt;/i&gt;. In the &lt;i&gt;PHYS_Flying&lt;/i&gt; type, the Actor is not affected by the effect of gravity. In the &lt;i&gt;PHYS_Rotating &lt;/i&gt;type only the rotation of the actor changes and the location doesn&#39;t change.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The Actor variables most used by the physics system are the &lt;i&gt;Velocity &lt;/i&gt;and &lt;i&gt;Acceleration &lt;/i&gt;vectors that change the position of the Actor. For rotation we have the variable &lt;i&gt;RotationRate &lt;/i&gt;that defines the speed of rotation. The actor also had the variable &lt;i&gt;DesiredRotation&lt;/i&gt;, but it was moved to the Pawn class. This variable is used to rotate a Pawn smoothly until it reaches the specified rotation in &lt;i&gt;DesiredRotation&lt;/i&gt;.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;I did a very simple example that only changes the physics type of the player to &lt;i&gt;PHYS_Flying&lt;/i&gt;. The following code defines a new GameInfo, to test it is necessary to set the &lt;i&gt;Game Type&lt;/i&gt; in the editor as UTGameFlying.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;class UTGameFlying extends UTGame;

function StartMatch()
{ 
 local UTPlayerController playerController;
 
 super.StartMatch();
 foreach LocalPlayerControllers(class &#39;UTPlayerController&#39;, playerController) 
 {
    if( playerController.pawn != None ) 
    {            
      playerController.pawn.SetPhysics(PHYS_Flying);            
    }
 }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhforuYqMllEqExGNUACk7KWAvvHfZhgVF-7pYLeL8IEiEhD7IQqM39_GfUyMh3ymQPXhkD_n5El5QEjkVeXswzYLwG3NgqiJs11UBq3lQSRGl0j_qGIlrvXzbiNdmXMIcZIkp7UdqrdgE/s1600/us26.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhforuYqMllEqExGNUACk7KWAvvHfZhgVF-7pYLeL8IEiEhD7IQqM39_GfUyMh3ymQPXhkD_n5El5QEjkVeXswzYLwG3NgqiJs11UBq3lQSRGl0j_qGIlrvXzbiNdmXMIcZIkp7UdqrdgE/s400/us26.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;For more information about Physics in UDK:&lt;br /&gt;
&lt;a href=&quot;http://udn.epicgames.com/Three/PhysicsHome.html&quot;&gt;Physics Home&lt;/a&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/3731217889524562461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/3731217889524562461'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/02/using-physics-in-unrealscript.html' title='Using Physics in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhforuYqMllEqExGNUACk7KWAvvHfZhgVF-7pYLeL8IEiEhD7IQqM39_GfUyMh3ymQPXhkD_n5El5QEjkVeXswzYLwG3NgqiJs11UBq3lQSRGl0j_qGIlrvXzbiNdmXMIcZIkp7UdqrdgE/s72-c/us26.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-7765027797005268858</id><published>2012-02-16T20:50:00.002-03:00</published><updated>2012-02-17T08:55:49.378-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Weapon Class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The Weapon class is a subclass of &lt;a href=&quot;http://romerounrealscript.blogspot.com/2012/02/pickupfactory-and-inventory-in.html&quot;&gt;Inventory&lt;/a&gt;. The Weapon System in UDK is very flexible for creating different types of weapons or usable items. The image below shows the existing subclasses of Weapon in UDK:&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ9k_tnhfOKDupEm4YICLWLIMWRHsbwbjhZtL-N9U65HhSE_xJD2BNny_BeDwKdfQoKUra-HyIGmgkI2tDb7P5QN9eX5iORAuV12Y4ZoFRSZf2TkqPLyKeYK28yMdt1DyYkmzOJ6NrCXE/s1600/us25a.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ9k_tnhfOKDupEm4YICLWLIMWRHsbwbjhZtL-N9U65HhSE_xJD2BNny_BeDwKdfQoKUra-HyIGmgkI2tDb7P5QN9eX5iORAuV12Y4ZoFRSZf2TkqPLyKeYK28yMdt1DyYkmzOJ6NrCXE/s1600/us25a.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Each weapon can have multiple &lt;b&gt;firing modes&lt;/b&gt;. The UDK uses two types: primary, which is fired with the left mouse button, and the secondary, which is fired with the right mouse button. However, other firing modes can be created. For each firing mode is necessary to define the &lt;b&gt;fire type&lt;/b&gt;. The UDK already has defined two fire types, the &lt;b&gt;Instant Fire&lt;/b&gt; that is used for very fast weapons such as a &lt;i&gt;Sniper Rifle&lt;/i&gt;. In this fire type, the bullet is not created. What happens at the time of the shooting is that a trace is done representing the path of the bullet to find any obstacle collision immediately. The other fire type is the &lt;b&gt;Projectile Fire&lt;/b&gt;. When the weapon is fired in this fire type, an object of &lt;i&gt;Projectile&lt;/i&gt; class is created with the information of speed and direction. The &lt;i&gt;Projectile&lt;/i&gt; class is responsible for the collision checking.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The fire types are defined in the Weapon class in an Enumeration (&lt;b&gt;enum&lt;/b&gt;). An enum is very useful to limit the possible values ​​that a variable can have. A dynamic &lt;b&gt;Array&lt;/b&gt; is used to define the fire type for each firing mode. Each position in the Array represents a firing mode. The index of an Array starts in zero, so the information of the primary firing mode is in the index zero and the information of the secondary firing mode is in the index one. The following code shows the declaration of the enum and the Array.&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;// Extract from Weapon &lt;/code&gt;&lt;code&gt;class&lt;/code&gt;&lt;code&gt; (Engine package)

enum EWeaponFireType
{
    EWFT_InstantHit,
    EWFT_Projectile,
    EWFT_Custom,
    EWFT_None
};

var Array&amp;lt;EWeaponFireType&amp;gt;  WeaponFireTypes;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;A good weapon example in UDK is the &lt;i&gt;Link Gun&lt;/i&gt;. This is the default weapon that the player gets when runs a game in UDK as UTGame. The Link Gun&#39;s primary firing mode is of type EWFT_Projectile that launches fast plasmas projectiles. The secondary firing mode is of type EWFT_InstantHit that fires a constant plasma beam as shown below.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7suDS-j9rrRO0n8GNHndqJAuOvyIuTSeVKuFR2JNvrQEGT2qgKw1XMezE_97D6RTL7YmSLz8nb3S4FvLVUwjD1LHSciJy0N76-7SXzOSjMTvEYp8cSWCohySOAbz5iU_cyEm-GhnXv6U/s1600/us25b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7suDS-j9rrRO0n8GNHndqJAuOvyIuTSeVKuFR2JNvrQEGT2qgKw1XMezE_97D6RTL7YmSLz8nb3S4FvLVUwjD1LHSciJy0N76-7SXzOSjMTvEYp8cSWCohySOAbz5iU_cyEm-GhnXv6U/s400/us25b.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The class that defines the Link Gun weapon is &lt;i&gt;UTWeap_LinkGun&lt;/i&gt;. In the defaultproperties block are defined the fire type and the class that represents the projectile for the primary firing mode as seen in the code below.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from UTWeap_LinkGun class (UTGame package)

defaultproperties
{
  //...

  WeaponFireTypes(0)=EWFT_Projectile
  WeaponProjectiles(0)=class&#39;UTProj_LinkPlasma&#39;

  //...
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The function of the Weapon class responsible for firing weapons of type EWFT_InstantHit is &lt;b&gt;InstantFire()&lt;/b&gt;. The function used in the type EWFT_Projectile to fire projectiles is &lt;b&gt;ProjectileFire()&lt;/b&gt;. Below is a sample code of the ProjectileFire() function in the UTWeapon class.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//Extract from UTWeapon class (UTGame package)

simulated function Projectile ProjectileFire()
{
    local vector        RealStartLoc;
    local Projectile    SpawnedProjectile;

    // tell remote clients that we fired, to trigger effects
    IncrementFlashCount();

    if( Role == ROLE_Authority )
    {
        // this is the location where the projectile is spawned.
        RealStartLoc = GetPhysicalFireStartLoc();

        // Spawn projectile
        SpawnedProjectile = Spawn(GetProjectileClass(),,, RealStartLoc);

        if( SpawnedProjectile != None &amp;amp;&amp;amp; !SpawnedProjectile.bDeleteMe )
        {
            SpawnedProjectile.Init( Vector(GetAdjustedAim( RealStartLoc )) );
        }

        // Return it up the line
        return SpawnedProjectile;
    }

    return None;
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;For more information about the Weapon class: &lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://udn.epicgames.com/Three/WeaponsTechnicalGuide.html&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Weapon System Technical Guide&lt;/span&gt;&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/7765027797005268858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/7765027797005268858'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/02/weapon-class-unrealscript.html' title='Weapon Class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ9k_tnhfOKDupEm4YICLWLIMWRHsbwbjhZtL-N9U65HhSE_xJD2BNny_BeDwKdfQoKUra-HyIGmgkI2tDb7P5QN9eX5iORAuV12Y4ZoFRSZf2TkqPLyKeYK28yMdt1DyYkmzOJ6NrCXE/s72-c/us25a.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-1075424526725312572</id><published>2012-02-02T21:10:00.001-03:00</published><updated>2012-02-03T10:25:46.598-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>PickupFactory and Inventory in UnrealScript</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESiGM6L70dQa5fH4cN3mr5e0bZ6VnxCRxuIJiB4vPIFMug_F3A88w_DQkuDE-pyKrInmDtuoNYt28zKvlYA2oYnn1-Ka0zopDxfFQlZ31pmGMe1_OgrLVGVkopsRY43tubda4HNufj0s/s1600/us24a.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESiGM6L70dQa5fH4cN3mr5e0bZ6VnxCRxuIJiB4vPIFMug_F3A88w_DQkuDE-pyKrInmDtuoNYt28zKvlYA2oYnn1-Ka0zopDxfFQlZ31pmGMe1_OgrLVGVkopsRY43tubda4HNufj0s/s400/us24a.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The &lt;i&gt;PickupFactory&lt;/i&gt; class was created to provide inventory items for players in the levels of the Unreal Tournament game. It is represented visually by a base and by the item that it provides as in the image above.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;i&gt;PickupFactory&lt;/i&gt; is a subclass of &lt;i&gt;NavigationPoint&lt;/i&gt; which is a subclass of &lt;i&gt;Actor&lt;/i&gt;. The tree class below shows the types of &lt;i&gt;PickupFactory&lt;/i&gt; available in UDK:&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPGSjKYYYLQDj3TiD8V7QgjFMC4gYn_FH8XphfBWiXr6rSMLWSGaLiJ0doqgPdyDEAx06qaMZ_UWO9nUQCdiWkKABzEQyzZ44A5EENDBKY1nsoJD7ot62mAXkT1b-HGFun8XdZfbOqha4/s1600/us24b.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPGSjKYYYLQDj3TiD8V7QgjFMC4gYn_FH8XphfBWiXr6rSMLWSGaLiJ0doqgPdyDEAx06qaMZ_UWO9nUQCdiWkKABzEQyzZ44A5EENDBKY1nsoJD7ot62mAXkT1b-HGFun8XdZfbOqha4/s1600/us24b.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;Another way to represent an inventory item in the level is using the &lt;i&gt;DroppedPickup&lt;/i&gt; class. This class is used when a &lt;i&gt;Pawn&lt;/i&gt; throws an inventory item in the level, this can happen when he dies.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The &lt;i&gt;InventoryManager&lt;/i&gt; class is responsible for managing the inventory items of a &lt;i&gt;Pawn&lt;/i&gt;. As an example of inventory items in Unreal Tournament we have the Jump Boots, the Berserker which increases the rate of fire, the UDamage that increases the damage, and all weapons are subclasses of the &lt;i&gt;Inventory&lt;/i&gt; class as can be seen in the image below.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhcMhX2a6QIFseoVlNy-VbWLMOQk30tBZtx3hNWhNwNiXqzai4gnwsOOM6tnKP6rFmuQhJVuC4IYmkS4wjCssky3U1XlOYS12bSjZsX-EByVDbhAhspI68-2v0QTgaC3cKrRBTITR94wQ/s1600/us24c.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhcMhX2a6QIFseoVlNy-VbWLMOQk30tBZtx3hNWhNwNiXqzai4gnwsOOM6tnKP6rFmuQhJVuC4IYmkS4wjCssky3U1XlOYS12bSjZsX-EByVDbhAhspI68-2v0QTgaC3cKrRBTITR94wQ/s1600/us24c.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;When a &lt;i&gt;Pawn&lt;/i&gt; touches a &lt;i&gt;PickupFactory&lt;/i&gt; or a &lt;i&gt;DroppedPickup&lt;/i&gt;, an object of &lt;i&gt;Inventory&lt;/i&gt; class is provided to the player through the function &quot;&lt;i&gt;Inventory.GiveTo(Pawn Other)&lt;/i&gt;&quot;. This function calls another function of &lt;i&gt;InventoryManager&lt;/i&gt; called &lt;i&gt;AddInventory()&lt;/i&gt; that checks if the new inventory item exists in a &lt;a href=&quot;http://en.wikipedia.org/wiki/Linked_list&quot;&gt;linked list&lt;/a&gt; of &lt;i&gt;Inventory&lt;/i&gt; objects before adding it. After this, the function &quot;&lt;i&gt;Inventory.GivenTo()&lt;/i&gt;&quot; is called which finally calls the function &quot;&lt;i&gt;Inventory.AdjustPawn()&lt;/i&gt;&quot; that is responsible for adding or removing the effect of the item in the &lt;i&gt;Pawn&lt;/i&gt; object.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The code below is from the &lt;i&gt;AddInventory()&lt;/i&gt; function of &lt;i&gt;InventoryManager&lt;/i&gt; class. In this function we can see the use of the linked list of objects of the Inventory class.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%; word-wrap: normal;&quot;&gt;&lt;code&gt;//In the InventoryManager class: 

simulated function bool AddInventory(Inventory NewItem, optional bool bDoNotActivate)
{
    local Inventory Item, LastItem;
    
    if( (NewItem != None) &amp;amp;&amp;amp; !NewItem.bDeleteMe )
    {
        // if we don&#39;t have an inventory list, start here
        if( InventoryChain == None )
        {
            InventoryChain = newItem;
        }
        else
        {
            // Skip if already in the inventory.
            for (Item = InventoryChain; Item != None; Item = Item.Inventory)
            {
                if( Item == NewItem )
                {
                    return FALSE;
                }
                LastItem = Item;
            }
            LastItem.Inventory = NewItem;
        }
        
        //Instigator is a variable that keeps a reference to the Pawn that gets the Item.
        NewItem.SetOwner( Instigator );
        NewItem.Instigator = Instigator;
        NewItem.InvManager = Self;
        NewItem.GivenTo( Instigator, bDoNotActivate);
        
        Instigator.TriggerEventClass(class&#39;SeqEvent_GetInventory&#39;, NewItem);
        return TRUE;
    }

    return FALSE;
}
&lt;/code&gt;&lt;/pre&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1075424526725312572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1075424526725312572'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/02/pickupfactory-and-inventory-in.html' title='PickupFactory and Inventory in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESiGM6L70dQa5fH4cN3mr5e0bZ6VnxCRxuIJiB4vPIFMug_F3A88w_DQkuDE-pyKrInmDtuoNYt28zKvlYA2oYnn1-Ka0zopDxfFQlZ31pmGMe1_OgrLVGVkopsRY43tubda4HNufj0s/s72-c/us24a.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-6761705597100617244</id><published>2012-01-08T23:00:00.001-03:00</published><updated>2012-01-09T12:30:32.001-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Camera Class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The Camera class is used to define the point of view of the player in the 3D game world. To move the camera during the game simply adjust its &lt;i&gt;Location&lt;/i&gt; and &lt;i&gt;Rotation&lt;/i&gt; properties. The Camera class works together with the Pawn and PlayerController classes to control its position and effects that occur during the game.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;In Unreal Tournament the default camera used is in first person. This camera is simple to define as we just need to get the point of view related to the eyes of the Actor that represents the player. This is done with this function in Pawn class:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; word-wrap: normal; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;GetActorEyesViewPoint( out vector out_Location, out Rotator out_Rotation )
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The third-person camera is used in some situations in the game Unreal Tournament, for example when the player enters a vehicle. Setting a third-person camera is much more complex because we must also consider whether there is any obstacle between the camera and the player. The code that calculates the position for this camera is in this function of UTPawn class:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; word-wrap: normal; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;bool CalcThirdPersonCam( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The Camera class has a function called &lt;b&gt;UpdateCamera(float DeltaTime)&lt;/b&gt; that is called every frame. This function calls another function &lt;b&gt;DoUpdateCamera(float DeltaTime)&lt;/b&gt; which calls &lt;b&gt;UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)&lt;/b&gt;. The function &lt;i&gt;UpdateViewTarget&lt;/i&gt; allows the Pawn class to set the camera position calling its &lt;b&gt;CalcCamera()&lt;/b&gt; function in the code snippet below:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; word-wrap: normal; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;//Inside Camera.UpdateViewTarget(out TViewTarget OutVT, float DeltaTime):
                
 TPawn = Pawn(OutVT.Target);
 // Give Pawn Viewtarget a chance to dictate the camera position.
 // If Pawn doesn&#39;t override the camera view, then we proceed with our own defaults
 if( TPawn == None || !&lt;b&gt;TPawn.CalcCamera&lt;/b&gt;(DeltaTime, OutVT.POV.Location, OutVT.POV.Rotation, OutVT.POV.FOV) )
 { 
   //camera default...
 }
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The code below is the function CalcCamera of the UTPawn class:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; word-wrap: normal; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
    // Handle the fixed camera

    if (bFixedView)
    {
        out_CamLoc = FixedViewLoc;
        out_CamRot = FixedViewRot;
    }
    else
    {
        if ( !IsFirstPerson() )    // Handle BehindView
        {
            CalcThirdPersonCam(fDeltaTime, out_CamLoc, out_CamRot, out_FOV);
        }
        else
        {
            // By default, we view through the Pawn&#39;s eyes..
            GetActorEyesViewPoint( out_CamLoc, out_CamRot );
        }

        if ( UTWeapon(Weapon) != none)
        {
            UTWeapon(Weapon).WeaponCalcCamera(fDeltaTime, out_CamLoc, out_CamRot);
        }
    }
    return true;
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;At the end of this code we can see that the function allows the weapon in use to do some adjustment to the camera through the &lt;b&gt;WeaponCalcCamera()&lt;/b&gt; function. I looked in the weapons classes of UTDemo that come with the UDK and none implements this function. An example of a weapon that should do this adjustment is the &lt;i&gt;Sniper Rifle&lt;/i&gt; in Zoom mode.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;For more information about Camera:&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;a href=&quot;http://udn.epicgames.com/Three/CameraTechnicalGuide.html&quot;&gt;Camera Technical Guide&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBj0HrHRsaEnve1P7DvdGFwQr-S-67AmHSKig19LbbZGjkiuccqmpWODYhfXdep96mcjYbHq4wtEMlwuQH7JVCc6cA-q2LyKKld88utjSmbMq_nv12GvXvoFqnc1azfuDz9_doSpgbDAo/s1600/us23.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;250&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBj0HrHRsaEnve1P7DvdGFwQr-S-67AmHSKig19LbbZGjkiuccqmpWODYhfXdep96mcjYbHq4wtEMlwuQH7JVCc6cA-q2LyKKld88utjSmbMq_nv12GvXvoFqnc1azfuDz9_doSpgbDAo/s400/us23.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Sniper Rifle Zoom in UT2004&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/6761705597100617244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/6761705597100617244'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/01/camera-class-unrealscript.html' title='Camera Class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBj0HrHRsaEnve1P7DvdGFwQr-S-67AmHSKig19LbbZGjkiuccqmpWODYhfXdep96mcjYbHq4wtEMlwuQH7JVCc6cA-q2LyKKld88utjSmbMq_nv12GvXvoFqnc1azfuDz9_doSpgbDAo/s72-c/us23.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-8302500567612537403</id><published>2012-01-02T07:14:00.004-03:00</published><updated>2012-01-09T12:41:51.486-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Using Rotators in UnrealScript</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;In UnrealScript the rotation of 3D objects is done through the use of a structure called &lt;b&gt;Rotator&lt;/b&gt; that is defined in the Object class as follows:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;struct immutable Rotator
{
    var() int Pitch, Yaw, Roll;
};
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Each of the integer variables Pitch, Yaw and Roll, represents the rotation around an axis. The keyword &quot;immutable&quot; is a structure modifier used to optimize the serialization of Rotator variables.&lt;br /&gt;
&lt;br /&gt;
The Unreal Engine uses integer values between -32768 and +32767 to represent the angle in degrees between -180 and 180, or 0 to 65535 for the angles of 0 to 360 degrees. This range of values corresponds to the capacity of a 16-bit integer variable and maybe is an inheritance from the 1st version of the Unreal Engine, because at this time the mathematical operations with integers were much faster than the operations done with float numbers.&lt;br /&gt;
&lt;br /&gt;
To help in the conversion of angles between degrees, radians and Unreal Rotation, some constants are defined in the Object class:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;const Pi = 3.1415926535897932;
const RadToDeg = 57.295779513082321600;    // 180 / Pi
const DegToRad = 0.017453292519943296;    // Pi / 180
const UnrRotToRad = 0.00009587379924285;// Pi / 32768
const RadToUnrRot = 10430.3783504704527;// 32768 / Pi
const DegToUnrRot = 182.0444;
const UnrRotToDeg = 0.00549316540360483;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;To use these constants just multiply by the desired value. For example, if we want to find out how much is 90 degrees in Unreal Rotation, do as follows:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;unreal90Degree = 90 * DegToUnrRot;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The Actor class has a variable called Rotation of type Rotator defined as follows:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;/** The actor&#39;s rotation; use SetRotation to change. */
var(Movement) const rotator    Rotation;
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;This variable is defined as &lt;b&gt;const&lt;/b&gt; (constant) indicating that its contents can not be changed. To change the rotation of an Actor you must use the SetRotation function:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;native(299) final function bool SetRotation( rotator NewRotation );
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The &lt;b&gt;native&lt;/b&gt; keyword indicates that this function is implemented in C++, so we can not see its source code, because in the UDK only comes UnrealScript source code. The &lt;b&gt;final&lt;/b&gt; keyword means that this function can not be overridden in a subclass.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;I made an example to demonstrate the use of the Rotator. I use a ship of Unreal Tournament and did a movement of rotation around each axis.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; word-wrap: normal; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;class TestRotator extends Actor
      placeable;
    
var float velRotation;

event Tick(float DeltaTime)
{
   local float deltaRotation;
   local Rotator newRotation;
   
   &lt;/code&gt;&lt;code&gt;deltaRotation&lt;/code&gt;&lt;code&gt; = &lt;/code&gt;&lt;code&gt;velRotation&lt;/code&gt;&lt;code&gt; * DeltaTime; 
   
   &lt;/code&gt;&lt;code&gt;newRotation&lt;/code&gt;&lt;code&gt; = Rotation;
   
   &lt;/code&gt;&lt;code&gt;newRotation&lt;/code&gt;&lt;code&gt;.Pitch += &lt;/code&gt;&lt;code&gt;deltaRotation&lt;/code&gt;&lt;code&gt;;
   &lt;/code&gt;&lt;code&gt;newRotation&lt;/code&gt;&lt;code&gt;.Yaw  += &lt;/code&gt;&lt;code&gt;deltaRotation&lt;/code&gt;&lt;code&gt;;   
   &lt;/code&gt;&lt;code&gt;newRotation&lt;/code&gt;&lt;code&gt;.Roll  += &lt;/code&gt;&lt;code&gt;deltaRotation&lt;/code&gt;&lt;code&gt;;   

   SetRotation( &lt;/code&gt;&lt;code&gt;newRotation&lt;/code&gt;&lt;code&gt; );       
}

defaultproperties
{
    &lt;/code&gt;&lt;code&gt;velRotation&lt;/code&gt;&lt;code&gt;=5000
   
    Begin Object Class=DynamicLightEnvironmentComponent Name=LightEnvironmentComp
        bEnabled = true
    End Object    
    Components.add( LightEnvironmentComp )
    
    Begin Object Class=SkeletalMeshComponent Name=SVehicleMesh
        SkeletalMesh=SkeletalMesh&#39;VH_Cicada.Mesh.SK_VH_Cicada&#39;
        AnimTreeTemplate=AnimTree&#39;VH_Cicada.Anims.AT_VH_Cicada&#39;
        PhysicsAsset=PhysicsAsset&#39;VH_Cicada.Mesh.SK_VH_Cicada_Physics&#39;
        AnimSets.Add(AnimSet&#39;VH_Cicada.Anims.VH_Cicada_Anims&#39;)
        LightEnvironment = LightEnvironmentComp
    End Object
    Components.add( SVehicleMesh )        
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8K3ZmNkjIFKpFOYNu8n3QYkOUI0By-L0AplS341nJkkJ_Wd1aZmQamP-udtU8uhr_p1IBHrOiHR2cO4pBSVV9Dxda394WZjX_cYKbeNG9ZCNCzGNSL8LMn-DiNfy0UaF5B22Cc8CkN3PL/s1600/us22.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8K3ZmNkjIFKpFOYNu8n3QYkOUI0By-L0AplS341nJkkJ_Wd1aZmQamP-udtU8uhr_p1IBHrOiHR2cO4pBSVV9Dxda394WZjX_cYKbeNG9ZCNCzGNSL8LMn-DiNfy0UaF5B22Cc8CkN3PL/s400/us22.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8302500567612537403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/8302500567612537403'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2012/01/using-rotators-in-unrealscript.html' title='Using Rotators in UnrealScript'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8K3ZmNkjIFKpFOYNu8n3QYkOUI0By-L0AplS341nJkkJ_Wd1aZmQamP-udtU8uhr_p1IBHrOiHR2cO4pBSVV9Dxda394WZjX_cYKbeNG9ZCNCzGNSL8LMn-DiNfy0UaF5B22Cc8CkN3PL/s72-c/us22.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-5508661305320185180</id><published>2011-12-18T23:03:00.004-03:00</published><updated>2012-01-09T12:41:06.132-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>PlayerInput Class (UnrealScript)</title><content type='html'>&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The PlayerInput class was created to help manage the player input. This class is an inner class of PlayerController class. This means that an object of PlayerInput class can not exist without an object of PlayerController class.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The PlayerInput class is declared this way:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;class PlayerInput extends Input within PlayerController
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
An inner class has direct access to variables and functions of the outer class. But if in the inner class there are variables / functions with the same name, you must use the keyword &quot;Outer&quot; to reference the outer class. It is always recommended to use the keyword &quot;Outer&quot; to avoid confusion in the code. As an example, the PlayerController class has a variable named &quot;bDemoOwner&quot;. To access it in the PlayerInput class, use:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;Outer.bDemoOwner
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The instance of the PlayerInput class is created in the function &quot;InitInputSystem()&quot; of PlayerController class as follows:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;PlayerInput = new(Self) InputClass;
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The &quot;InputClass&quot; is defined in the PlayerController&#39;s DefaultProperties and &quot;Self&quot; is the reference of PlayerController class that will be stored in the Outer object of PlayerInput class.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;-----&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;As seen in the article on &lt;a href=&quot;http://romerounrealscript.blogspot.com/2011/10/key-binds-and-exec-functions-in.html&quot;&gt;Key Binds and Exec Functions&lt;/a&gt;, the configuration file &quot;DefaultInput.ini&quot; is used to define the commands that can be executed by the player.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;In the PlayerInput class are defined variables that will store some information related to Axes. These variables have a modifier called &lt;b&gt;input&lt;/b&gt; making them accessible to the Unreal input system.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Below are some examples of variables in the PlayerInput class:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;var input    float    aBaseX;
var input    float    aBaseY;
var input    float    aBaseZ;
var input    float    aMouseX;
var input    float    aMouseY;
var input    float    aForward;
var input    float    aTurn;
var input    float    aStrafe;
var input    float    aUp;
var input    float    aLookUp;

var input    float    aRightAnalogTrigger;
var input    float    aLeftAnalogTrigger;
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Example of a binding to one of these variables:&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;.Bindings=(Name=&quot;GBA_MoveForward&quot;,Command=&quot;Axis aBaseY Speed=1.0&quot;)
&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The action GBA_MoveForward assign the position of the axis of the input device directly to the variable aBaseY. The &quot;Speed&quot; attribute is used to multiplier the value of the axis.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;-----&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;When a function is bind to a key/button, it will only be called once when the key is pressed. The function will only be called again when you release and press the key/button. This way we can not implement actions that are performed while the key is being pressed.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;To solve this problem we can use an exec function that receives a boolean value as parameter. When the key is pressed the function is called with the value &quot;true&quot; and when the key is released (&lt;b&gt;Onrelease&lt;/b&gt;) the function is called with the value &quot;false&quot;.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;As an example, in the Unreal Tournament the Score Table is displayed while the F1 key is being pressed. When you release the F1 key the Score Table is no longer displayed.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The code below shows the binding and the function that stores the boolean value.&lt;/div&gt;&lt;pre style=&quot;background-color: #eeeeee; border: 1px dashed rgb(153, 153, 153); color: black; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px; line-height: 14px; overflow: auto; word-wrap: normal; padding: 5px; width: 100%;&quot;&gt;&lt;code&gt;//In DefaultInput.ini:

.Bindings=(Name=&quot;GBA_ShowScores&quot;,Command=&quot;SetShowScores true | Onrelease SetShowScores false&quot;)


//In HUD &lt;/code&gt;&lt;code&gt;class &lt;/code&gt;&lt;code&gt;(Engine package):

/** sets bShowScores to a specific value (not toggle) */
exec function SetShowScores(bool bNewValue)
{ 
    bShowScores = bNewValue; 
}

&lt;/code&gt;&lt;/pre&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLr-07OKVoysHtqnLaZtlebNv66IKAWadZkEY7qKeCXplsf8aDxp8UFSrOH7lJqtKBGwK8JbwrGBwfmkP6ZDcniURwHki3UZgX6N2yQM450Ago5bT0TIRCqL31Y4Zw8hv51HMyDR8y9xU/s1600/us21.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;225&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLr-07OKVoysHtqnLaZtlebNv66IKAWadZkEY7qKeCXplsf8aDxp8UFSrOH7lJqtKBGwK8JbwrGBwfmkP6ZDcniURwHki3UZgX6N2yQM450Ago5bT0TIRCqL31Y4Zw8hv51HMyDR8y9xU/s400/us21.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/5508661305320185180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/5508661305320185180'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2011/12/playerinput-class-unrealscript.html' title='PlayerInput Class (UnrealScript)'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLr-07OKVoysHtqnLaZtlebNv66IKAWadZkEY7qKeCXplsf8aDxp8UFSrOH7lJqtKBGwK8JbwrGBwfmkP6ZDcniURwHki3UZgX6N2yQM450Ago5bT0TIRCqL31Y4Zw8hv51HMyDR8y9xU/s72-c/us21.PNG" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-4505876340997549930.post-1609772514300627047</id><published>2011-11-25T22:55:00.001-03:00</published><updated>2011-11-25T23:08:56.578-03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="UnrealScript"/><title type='text'>Exploring the UnrealScript source code with UnCodeX</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The largest and most updated reference about UnrealScript is the source code that comes with the UDK. But sometimes it&#39;s difficult to follow the source code and understand the relationship between the classes.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;To help in this task we will use a tool called &lt;i&gt;UnCodeX&lt;/i&gt;, which was developed by Michiel &#39;elmuerte&#39; Hendriks, and can be downloaded on the &lt;a href=&quot;http://sourceforge.net/projects/uncodex&quot;&gt;project page&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The installation is simple, in the first execution of the UnCodeX a message box will appear asking you to change the settings. Choose &quot;Yes&quot;. If you want to change the settings later, access the menu: &quot;Tree -&amp;gt; Settings...&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;In the setting &quot;Source Paths&quot; add the folder &quot;\Development\Src&quot; of the UDK, as in the image below.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7eKRyXpbw3SJpHbgSKBOEc6bx2T1CFHSydnuTERV3BNVq7Gt9ln3Q-i3ipdVuXwPkyOIR5L4eLEpaTm66azisQNPxWinjUAOyhXHGNXoaLKcgYauM5ooPaflFznHeSS3zQ_MweGqlUf0/s1600/uncodex1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7eKRyXpbw3SJpHbgSKBOEc6bx2T1CFHSydnuTERV3BNVq7Gt9ln3Q-i3ipdVuXwPkyOIR5L4eLEpaTm66azisQNPxWinjUAOyhXHGNXoaLKcgYauM5ooPaflFznHeSS3zQ_MweGqlUf0/s400/uncodex1.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The UnCodeX will analyze all the packages and classes to display them as follows:&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0VWhLT_yvWnOTTXAnlS2KmzNKBfNxfVo-b5D0R5Q9rJjbRw7PCDjVqTNv5ZmKOCfnpYur97JjXn8yeJOIyimDU3i_rMFLXjkbqEwAPjmo1vzwMxRigrSCFd10t5CtfewBx3pnav3WUdE/s1600/uncodex2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;192&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0VWhLT_yvWnOTTXAnlS2KmzNKBfNxfVo-b5D0R5Q9rJjbRw7PCDjVqTNv5ZmKOCfnpYur97JjXn8yeJOIyimDU3i_rMFLXjkbqEwAPjmo1vzwMxRigrSCFd10t5CtfewBx3pnav3WUdE/s400/uncodex2.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;As an example we will research and analyze a class. In the &lt;a href=&quot;http://romerounrealscript.blogspot.com/2011/11/playing-sounds-in-unrealscript.html&quot;&gt;previous tutorial&lt;/a&gt; I used the static mesh of &quot;&lt;i&gt;Jump Boots&lt;/i&gt;&quot; of the Unreal Tournament. Let&#39;s try to find the class that implements the &quot;&lt;i&gt;Jump Boots&lt;/i&gt;&quot;.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Access the Menu: &quot;Find -&amp;gt; Find Class ...&quot;, type in the search query &quot;&lt;i&gt;boots&lt;/i&gt;&quot; and check the &quot;Search from the top&quot; as in the image, so that the research is done from the base Object class.&lt;/div&gt;&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC-H6DGNZmEUYR7EXLKn089BGxc47FVpVVPzHh1LZ67a579xe2ZISJqQ9p0iPledrZMFGQJC-vd_cktRC_QGN-eSgU4A47VHamU8eI4V6b5VCcs63B39sqL-guLKzPO-8QHjRo7KPLEYk/s1600/uncodex3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC-H6DGNZmEUYR7EXLKn089BGxc47FVpVVPzHh1LZ67a579xe2ZISJqQ9p0iPledrZMFGQJC-vd_cktRC_QGN-eSgU4A47VHamU8eI4V6b5VCcs63B39sqL-guLKzPO-8QHjRo7KPLEYk/s1600/uncodex3.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps atn&quot;&gt;Press &quot;&lt;/span&gt;OK&quot; &lt;span class=&quot;hps&quot;&gt;to start the search&lt;/span&gt;. &lt;span class=&quot;hps&quot;&gt;The&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;UnCodex&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;found the&lt;/span&gt; &lt;span class=&quot;hps atn&quot;&gt;class &quot;&lt;/span&gt;&lt;i&gt;&lt;span class=&quot;&quot;&gt;UTJumpBoots&lt;/span&gt;&lt;/i&gt;&lt;span class=&quot;&quot;&gt;&quot; which is&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;exactly what&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;we wanted&lt;/span&gt;. &lt;span class=&quot;hps&quot;&gt;If we want to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;continue the search&lt;/span&gt;, press F3 &lt;span class=&quot;hps&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;&quot;Find&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;Next&quot;&lt;/span&gt;.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiePRyvawTqiWTroCfxkqK_N1bDmz_Ro5QC4ePTkGQ8P4kobsTBz1X1zwU-XwlpvSHWPagHT2FmH3B5_odS7SiW2Qepa4SoujF7piSQZRtcDIc8xzX8kgXFAwyX7N4wcQTSEIQEp-qsql4/s1600/uncodex4.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiePRyvawTqiWTroCfxkqK_N1bDmz_Ro5QC4ePTkGQ8P4kobsTBz1X1zwU-XwlpvSHWPagHT2FmH3B5_odS7SiW2Qepa4SoujF7piSQZRtcDIc8xzX8kgXFAwyX7N4wcQTSEIQEp-qsql4/s1600/uncodex4.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;&lt;span class=&quot;&quot; id=&quot;result_box&quot; lang=&quot;en&quot;&gt;&lt;span class=&quot;hps&quot;&gt;Right&lt;/span&gt;-clicking &lt;span class=&quot;hps&quot;&gt;in the class,&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;we can see that&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;it&#39;s in the&lt;/span&gt; &lt;span class=&quot;hps atn&quot;&gt;package &quot;&lt;/span&gt;&lt;i&gt;UTGameContent&lt;/i&gt;&quot;. &lt;span class=&quot;hps&quot;&gt;Let&#39;s choose&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;the option &quot;&lt;i&gt;Show&lt;/i&gt;&lt;/span&gt;&lt;i&gt; &lt;span class=&quot;hps&quot;&gt;Properties...&lt;/span&gt;&lt;/i&gt;&quot; &lt;span class=&quot;hps&quot;&gt;to have&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;an&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;overview of&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;variables and functions&lt;/span&gt; &lt;span class=&quot;hps&quot;&gt;of this class&lt;/span&gt;&lt;span class=&quot;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRD7RWbyUOlt_nHwVECrdHgEyXptFdaeahfW2O2ylrfibyEyuc3GSiucS3kjZzh5eu-UhvJRZhyphenhyphenxPgqhq9SOVPhU6WhQIHkXoJZbglQcKOzdb7kgOhjyMd_0uEZ41y4kRHhd25qkN8uKo/s1600/uncodex5.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRD7RWbyUOlt_nHwVECrdHgEyXptFdaeahfW2O2ylrfibyEyuc3GSiucS3kjZzh5eu-UhvJRZhyphenhyphenxPgqhq9SOVPhU6WhQIHkXoJZbglQcKOzdb7kgOhjyMd_0uEZ41y4kRHhd25qkN8uKo/s1600/uncodex5.PNG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Looking at the source code of this class we can see some functions that deal with the multiplayer aspect of Unreal Tournament.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s start by looking at the &quot;&lt;i&gt;defaultproperties&lt;/i&gt;&quot; block. It defined the StaticMesh that will represents this class in the game. Some values are assigned for the variables, such as the variable &quot;&lt;i&gt;Charges&lt;/i&gt;&quot; which indicates how many times the boots can be used.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHCmn1jMJsnq7ACmXZZek6Z1D3IJPd7OCCXnrwdYFyU_kssIwFkp4_IoWKWEZ1KvOIngY5LyAWeY1Qccw1MPi1mgkFuNeWQWAa1guXiQt5PWoabgqefUC8l9BzS5-tRYKThiU5vagW4k4/s1600/uncodex6.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;247&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHCmn1jMJsnq7ACmXZZek6Z1D3IJPd7OCCXnrwdYFyU_kssIwFkp4_IoWKWEZ1KvOIngY5LyAWeY1Qccw1MPi1mgkFuNeWQWAa1guXiQt5PWoabgqefUC8l9BzS5-tRYKThiU5vagW4k4/s400/uncodex6.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;The &lt;i&gt;AdjustPawn()&lt;/i&gt; function adds or removes the bonus of the boots on the player. In this function we can see an comments error caused by a Copy/Paste operation.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwy4u6abi-dNF7LdP001qKSQR3kgr5b6eb8OaVT48DSMnbXuBplTgl3BorU_MJIHs62ZGLOJUkHV8LHm_sm0ccXIkz47Jp1f9MChHqNgqJwwFYBYnERylDZasvVkiFvpV-kmn26J46wTg/s1600/uncodex7.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwy4u6abi-dNF7LdP001qKSQR3kgr5b6eb8OaVT48DSMnbXuBplTgl3BorU_MJIHs62ZGLOJUkHV8LHm_sm0ccXIkz47Jp1f9MChHqNgqJwwFYBYnERylDZasvVkiFvpV-kmn26J46wTg/s400/uncodex7.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana,sans-serif; text-align: justify;&quot;&gt;Another interesting function is &lt;i&gt;BotDesireability()&lt;/i&gt; that calculates the interest of the bot for this item. Basically, the function checks if the bot already has one and how many times can still be used.&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_34S7whZYpnrkWLAKl6ZngdqvCHcxdhzOz8AyfPy-OyrPz50jrrMRhJSF-NwBevDEZsXivmexeFazMHgI4w2cYc4EHrzkW97n_FqQqRBwGgJOD3na1Xijj9lyw9mqcxlN2HFaWUtxPvA/s1600/uncodex8.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;117&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_34S7whZYpnrkWLAKl6ZngdqvCHcxdhzOz8AyfPy-OyrPz50jrrMRhJSF-NwBevDEZsXivmexeFazMHgI4w2cYc4EHrzkW97n_FqQqRBwGgJOD3na1Xijj9lyw9mqcxlN2HFaWUtxPvA/s400/uncodex8.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Verdana,sans-serif;&quot;&gt;The main goal of this tutorial is to show that you can learn many things about UnrealScript viewing the source code that comes with UDK.&lt;/span&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1609772514300627047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4505876340997549930/posts/default/1609772514300627047'/><link rel='alternate' type='text/html' href='http://romerounrealscript.blogspot.com/2011/11/exploring-unrealscript-source-code-with.html' title='Exploring the UnrealScript source code with UnCodeX'/><author><name>Marcos Romero</name><uri>http://www.blogger.com/profile/14211365149465818422</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAYMI5R7qTeqfz7wkk8n2QLhe6qRFouXYS_djQf-u5EV92rDs4U0gSmKncEJWpGHAdEWr5bHNt91Zum_nUQjikGuYxwQMxWdDK1SFI3OFLMsUWlM5-cKYY4CSuJkBblhk/s113/Romero2021_Blog.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7eKRyXpbw3SJpHbgSKBOEc6bx2T1CFHSydnuTERV3BNVq7Gt9ln3Q-i3ipdVuXwPkyOIR5L4eLEpaTm66azisQNPxWinjUAOyhXHGNXoaLKcgYauM5ooPaflFznHeSS3zQ_MweGqlUf0/s72-c/uncodex1.PNG" height="72" width="72"/></entry></feed>