<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";
        mso-fareast-language:EN-AU;}
span.sy4
        {mso-style-name:sy4;}
span.me2
        {mso-style-name:me2;}
span.br0
        {mso-style-name:br0;}
span.kw4
        {mso-style-name:kw4;}
span.kw2
        {mso-style-name:kw2;}
span.sy3
        {mso-style-name:sy3;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-AU link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi All,<o:p></o:p></p><p class=MsoNormal>So I thought I would try to go through the Gettings Started: Introduction to UE4 Programming tutorial (http://www.youtube.com/playlist?list=PLZlv_N0_O1gb5xvsc7VM7pfoRAKLuIcFi) and convert it to C# using Mono of UE. <o:p></o:p></p><p class=MsoNormal>This required me to convert the PlayerCharacter to c#. I’ve gone through and done this but I’m trying to figure out now how to set it up as the default player character. Basing it on this tutorial <a href="https://wiki.unrealengine.com/First_Person_Shooter_C%2B%2B_Tutorial">https://wiki.unrealengine.com/First_Person_Shooter_C%2B%2B_Tutorial</a> I can see you need to setup a new game mode in code and then initialise the DefaultPlayerPawn to the blueprint inherited from the custom PlayerCharacter. In C++ it looks like this<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>AFPSGameMode</span><span class=sy4><span style='font-size:12.0pt;color:teal'>::</span></span><span class=me2><span style='font-size:12.0pt;color:#007788'>AFPSGameMode</span></span><span class=br0><span style='font-size:12.0pt;color:green'>(</span></span><span class=kw4><span style='font-size:12.0pt;color:blue'>const</span></span><span style='font-size:12.0pt;color:black'> </span><span class=kw2><span style='font-size:12.0pt;color:blue'>class</span></span><span style='font-size:12.0pt;color:black'> FPostConstructInitializeProperties</span><span class=sy3><span style='font-size:12.0pt;color:#000040'>&</span></span><span style='font-size:12.0pt;color:black'> PCIP</span><span class=br0><span style='font-size:12.0pt;color:green'>)</span></span><span style='font-size:12.0pt;color:black'><o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span class=sy4><span style='font-size:12.0pt;color:teal'>:</span></span><span style='font-size:12.0pt;color:black'> Super</span><span class=br0><span style='font-size:12.0pt;color:green'>(</span></span><span style='font-size:12.0pt;color:black'>PCIP</span><span class=br0><span style='font-size:12.0pt;color:green'>)</span></span><span style='font-size:12.0pt;color:black'><o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span class=br0><span style='font-size:12.0pt;color:green'>{<o:p></o:p></span></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>      // set default pawn class to our Blueprinted character<o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>      static ConstructorHelpers::FObjectFinder<UBlueprint> PlayerPawnObject(TEXT("Blueprint'/Game/Blueprints/BP_FPSCharacter.BP_FPSCharacter'"));<o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>      if (PlayerPawnObject.Object != NULL)<o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>      {<o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>             DefaultPawnClass = (UClass*)PlayerPawnObject.Object->GeneratedClass;<o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'>      }<o:p></o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span class=br0><span style='font-size:12.0pt;color:green'>}<o:p></o:p></span></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'>I’m no C++ expert so I’m not sure if I am missing something but I can’t figure out how to convert this in the C# Mono for UE equivalent. So far I have this<o:p></o:p></pre><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></pre><p class=MsoNormal><span style='font-size:12.0pt;font-family:Consolas;color:#333333;mso-fareast-language:EN-AU'>    </span><span style='font-size:12.0pt;font-family:Consolas;color:#009695;mso-fareast-language:EN-AU'>public</span><span style='font-size:12.0pt;font-family:Consolas;color:#333333;mso-fareast-language:EN-AU'> </span><span style='font-size:12.0pt;font-family:Consolas;color:#009695;mso-fareast-language:EN-AU'>class</span><span style='font-size:12.0pt;font-family:Consolas;color:#333333;mso-fareast-language:EN-AU'> </span><span style='font-size:12.0pt;font-family:Consolas;color:#3364A4;mso-fareast-language:EN-AU'>CSharpGameMode</span><span style='font-size:12.0pt;font-family:Consolas;color:#333333;mso-fareast-language:EN-AU'> : </span><span style='font-size:12.0pt;font-family:Consolas;color:#3364A4;mso-fareast-language:EN-AU'>GameMode</span><span style='font-size:12.0pt;font-family:Consolas;mso-fareast-language:EN-AU'><br><span style='color:#333333'>    {</span><br><span style='color:#333333'>        </span><i><span style='color:#888888'>// Constructor called when creating or loading an object</span></i><br><span style='color:#333333'>        </span><span style='color:#009695'>protected</span><span style='color:#333333'> </span><span style='color:#3364A4'>CSharpGameMode</span><span style='color:#333333'>(</span><span style='color:#3364A4'>PostConstructInitializeProperties</span><span style='color:#333333'> pcip) : </span><span style='color:#009695'>base</span><span style='color:#333333'>(pcip)</span><br><span style='color:#333333'>        {</span><br><span style='color:#333333'>            </span><span style='color:#009695'>var</span><span style='color:#333333'> playerPawnObject = </span><span style='color:#009695'>new</span><span style='color:#333333'> </span><span style='color:#3364A4'>ObjectFinder</span><span style='color:#333333'><</span><span style='color:#3364A4'>Blueprint</span><span style='color:#333333'>>();</span><br><span style='color:#333333'>            playerPawnObject.Initialize(</span><span style='color:#F57D00'>"Blueprint'/Game/Blueprints/PlayerCharacter.PlayerCharacter'"</span><span style='color:#333333'>);</span><br><br><span style='color:#333333'>            </span><span style='color:#009695'>if</span><span style='color:#333333'> (playerPawnObject.Object != </span><span style='color:#009695'>null</span><span style='color:#333333'>)</span><br><span style='color:#333333'>            {</span><br><span style='color:#333333'>                DefaultPawnClass = </span><i><span style='color:#888888'>//<------- How do i get SubclassOf     <Pawn> from the ObjectFinder;</span></i><br><span style='color:#333333'>            }</span><br><span style='color:#333333'>        }</span><br><br><span style='color:#333333'>        </span><i><span style='color:#888888'>// Constructor for hot-reloading. UProperties will already be initialized, but any purely managed fields or data</span></i><br><span style='color:#333333'>        </span><i><span style='color:#888888'>// will need to be set up</span></i><br><span style='color:#333333'>        </span><span style='color:#009695'>protected</span><span style='color:#333333'> </span><span style='color:#3364A4'>CSharpGameMode</span><span style='color:#333333'>(</span><span style='color:#3364A4'>IntPtr</span><span style='color:#333333'> nativeObject) : </span><span style='color:#009695'>base</span><span style='color:#333333'>(nativeObject)</span><br><span style='color:#333333'>        {</span><br><br><span style='color:#333333'>        }</span><br><span style='color:#333333'>    }</span></span><span style='font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:EN-AU'> <o:p></o:p></span></p><pre style='line-height:14.4pt;background:#F9F9F9;vertical-align:top'><span style='font-size:12.0pt;color:black'><o:p> </o:p></span></pre></div></body></html>