UE3 - UT3 Unwanted duplication between dynamic array elements.

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

_LagMasterSam_

New Member
Mar 25, 2006
20
0
0
www.truetrix.com
This is a little difficult to explain so I'll use images to help explain. But first I'll show the code that is involved.

Base package classes

Code:
class TTVolume extends Volume
    placeable;

/** TTVolume parameters can vary depending upon the current
objective for a player or team.*/
var() editinline array< class<TTObjectiveSet> > ObjectiveSets;

Code:
class TTObjectiveSet extends Object
    abstract
    editinlinenew
    Collapsecategories;

Version based package classes

Code:
class TTObjectiveSetX extends TTObjectiveSet
    hidecategories(Object)
    AutoExpandCategories(TTObjectiveSetX);

/** This set is activated when this objective is reached.*/
var() int StartObj;
/** This set is de-activated when this objective is reached.*/
var() int StopObj;
/** These Actions will be active from Start Objective to Stop Objective.*/
var() editinline array< class<TTAction> > Actions;

Code:
class TTAction extends Object
    abstract
    editinlinenew
    Collapsecategories
    hidecategories(Object)
    AutoExpandCategories(TTAction);

Code:
class TTA_ChangePowerups extends TTAction;

struct PowerupData
{
    var() class<UTTimedPowerup> Powerup;
    var() int AddTime;
    var() int SubtractTime;
    var() int MinTime;
    var() int MaxTime;
    var() bool bRemovePowerup;
};

var() array< PowerupData > PowerupChange;

/** Remove all powerups the player may be carrying. */
var() bool bRemoveAll;

1. I start by adding two "objective sets" to my volume.

TTStart.jpg


2. Then I populate various settings on the first "objective set"

TTFirst.jpg


3. Now, when I check the other "objective set", all the values from the first have been duplicated to the second. If I change any values they are duplicated to the other "objective set"

TTSecond.jpg


Am I doing something wrong? Is there anyway to fix this?
 

Continuum

Lobotomistician
Jul 24, 2005
1,305
0
0
43
Boise
you're not using instances
?

What could be happening is that you createed the 2 objectives initially but they are not actually 2 different objects but are 2 references to the same instance (1 object) or it could be that some of the properties are static which means even if you have 2 instances the values of the static variables are shared between all instances of that class.

Can't really tell from the code posted.
 

Jrubzjeknf

Registered Coder
Mar 12, 2004
1,276
0
36
36
The Netherlands

An instance is an object. Classes (the blueprints of objects) are not instantiated.

OP uses this:

Code:
var() editinline array< class<TTObjectiveSet> > ObjectiveSets;

With this, he modifies the default values of the variables. That's why the same values show up for each variable in each entry. All he needs to do, is remove the class definition.
 

_LagMasterSam_

New Member
Mar 25, 2006
20
0
0
www.truetrix.com
An instance is an object. Classes (the blueprints of objects) are not instantiated.

OP uses this:

Code:
var() editinline array< class<TTObjectiveSet> > ObjectiveSets;

With this, he modifies the default values of the variables. That's why the same values show up for each variable in each entry. All he needs to do, is remove the class definition.

Yes. Removing class<> solves the problem. I thought that adding editinlinenew would cause the object to be created. I didn't realize that I could remove class<> and still select between different subclass types in UED from a dropdown menu. I though class<> was required for that. It's all clear to me now though. ;)
 

Continuum

Lobotomistician
Jul 24, 2005
1,305
0
0
43
Boise
An instance is an object. Classes (the blueprints of objects) are not instantiated.

OP uses this:

Code:
var() editinline array< class<TTObjectiveSet> > ObjectiveSets;
With this, he modifies the default values of the variables. That's why the same values show up for each variable in each entry. All he needs to do, is remove the class definition.

/offtopic
Does the class object have any reflection type methods?
 

Jrubzjeknf

Registered Coder
Mar 12, 2004
1,276
0
36
36
The Netherlands
And there's no such thing as a 'class object', and if there were, please refrain from using it. :p A class is a class, which is the blueprint for an object. Instantiation (or spawning) this class gives you an object, which exists somewhere in the UT's virtual world.
 

_LagMasterSam_

New Member
Mar 25, 2006
20
0
0
www.truetrix.com
And there's no such thing as a 'class object', and if there were, please refrain from using it. :p A class is a class, which is the blueprint for an object. Instantiation (or spawning) this class gives you an object, which exists somewhere in the UT's virtual world.

Yes. I'm aware of that. I thought editinlinenew would create an object of the class if I selected the class from the drop down box in Ued. I misunderstood the available documentation for editinlinenew.
 

Continuum

Lobotomistician
Jul 24, 2005
1,305
0
0
43
Boise
What is a reflection type method?

Reflection basically lets you discover what type of object, its properties, methods, and then be able to instantiate it and use it. Probably would be rare to see it used in a game except maybe in the UI or the editor. The base component is usually an object called Class (uppercase C in java) or Type (in .NET) which contains metadata on a class's (lowercase c) fields, methods etc..

If the engine does support it you could create a really powerful IDE for UrealScript

http://java.sun.com/docs/books/tutorial/reflect/
http://www.odetocode.com/Articles/288.aspx
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
There's limited reflection ability in UnrealScript, but you can't use it to e.g. call random methods or access random properties. Well, there was a way to access unknown properties in UE1 and 2, but it was removed in UE3. You should really use delegates, abstract parent classes or interfaces if you need to access objects in specific ways that you otherwise don't know anything about.