UE3 - UDK How do I create an object automatically on startup?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Nathaniel3W

Member
Nov 11, 2012
48
0
6
I've figured out how to make an object. It works just fine when I do this:

Code:
class MyUnrealGame01PlayerInput extends PlayerInput within MyUnrealGame01PlayerController;
var TestObject TheTestObject;
var string TestData;

function CreateTestObject()
{
	TheTestObject = new class'TestObject';
}

simulated exec function TestFunction1()
{
	ClientMessage("Creating object");
	CreateTestObject();
}

simulated exec function TestFunction2()
{
	TestData = TheTestObject.TestFunction1();
	ClientMessage("Object function test 1: "$TestData);
}

And I know it's working because the log returns a Script Warning: Accessed None if I run TestFunction2() before TestFunction1(). And if I run TestFunction1(), then TestFunction2(), then TheTestObject.TestFunction1() returns a "testing... testing..." in TestFunction2().

So I'm able to make an object inside my PlayerInput class. Now how do I make an object automatically when the game starts? I've been able to do things from event PostLogin() inside my FrameworkGame class, but events like that don't seem to do anything inside my PlayerInput class.

I also tried starting at the event PostLogin() in FrameworkGame, and from there calling MyUnrealGame01PlayerController.CreateTestObject(), but that doesn't work either.

Any advice?
 

Nathaniel3W

Member
Nov 11, 2012
48
0
6
Thanks for all your help Angel_Mapper. I really appreciate it. I've taken a look at some of your work and I hope to be able to do things like that someday.

I'm trying to get things working inside PostBeginPlay, but when I do this...

Code:
simulated event PostBeginPlay()
{
	super.PostBeginPlay();
}

...then I get this error:

error : Accessing a member of PlayerInput's within class through a context expression requires explicit 'Outer'

I've tried inserting a ".outer" just about every place I think one would fit, but I'm only guessing, and apparently guessing wrong. Can you help clarify that error message for me and/or tell me how to fix it? Thanks again.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
Non-Actor objects do not have automagically called start-up functions.

The error message is caused by language feature for classes declared within other classes. In such classes you can write code that implicitly uses members of the outer class. The call specifiers super and global cannot be used on other objects, which includes the implicit access to the outer object's members.