Class variables resetting between child classes

  • 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.

elmafiacs

New Member
May 23, 2005
1
0
0
I'm not English, so I don't know how to explain it with words.
You better look at the code, please.

Code:
// FatherClass.uc
class FatherClass extends Object;
var UIConsole Con;
var ChildClass Child;

function Initialize()
{
  Child=new(none)class'ChildClass';
  Con=new(none)class'UIConsole';
  Con=Con.GetUIConsole();
  Con.Message("Hi there", 1.0);
  Child.Initialize();  // the message that the child class has to show does not appear...
}

Code:
// ChildClass.uc
class ChildClass extends FatherClass;
function Initialize()
{
  // this condition executes, but I already initialized the console in FatherClass...
  if(Con==None) ConsoleCommand("exit");
  Con.Message("Hi there from ChildClass.Initialize", 1.0);
}

Code:
// Touch event on a trigger, for example
event Touch(Actor Other)
{
  F=new(none)class'FatherClass';
  F.Initialize();
}

Thanks in advance.
 

Dandeloreon1984

CXP Director
Jan 31, 2004
1,303
0
0
i think your con creation method isn't working properly, please take a look at ut2004's code for attaching player replication info... and also see about doing the is child of check within the initialize function.
 

JonAzz

UA Mapper
Aug 1, 2003
1,180
0
0
35
North of Philadelphia
I do not think that parent classes/function can access function in a child class. from what I know the parent class knows nothing about the child class.
 

draconx

RuneUT
Jun 26, 2002
325
0
0
36
Waterloo, Canada
Here is your problem:

The childclass is 100% separate from the parent class. As a result, when the childclass's Initialize() routine is executed, Con is None. Since you are not calling Super.Initialize(); in the child class, Con does not get set.
 

Dandeloreon1984

CXP Director
Jan 31, 2004
1,303
0
0
i found the issue with your classes... please use the following code to fix it...
Updated Father Class Code:
Code:
// FatherClass.uc
class FatherClass extends Object;
var UIConsole Con;
var ChildClass Child;

function Initialize()
{
    Child=new(none)class'ChildClass';
    Con=new(none)class'UIConsole';
    Con=Con.GetUIConsole();
    Con.Message("Hi there", 1.0);
    // next line is not neccessary.
    // Child.Initialize();  // the message that the child class has to show does not appear...
    }

updated code for childclass:
Code:
// ChildClass.uc
class ChildClass extends FatherClass;
function Initialize()
{

    super.Initialize(); // this is what you need.
    // this condition executes, but I already initialized the console in FatherClass...
    if(Con==None) ConsoleCommand("exit");
    Con.Message("Hi there from ChildClass.Initialize", 1.0);
    }


on a side note, initialize isn't very useful... make a new function with the use of the actor from the trigger, and check the other actor that's available to get the pawn class, and the controller from that... that way it is not going to all other players and also reduces accessed none's.