Newbie question about archetypes and arrays

I declare an array containing archetypes:

var() archetype array<scene> Scenes;

Then in the editor I can fill the array by manually selecting the archetypes and adding them.
Later in game I can spawn these archetypes from the array. No problem, all works, I use this method a lot.

Problem is when I try to fill the array from a function in the script:

Scenes[0] = scene’TEST.SceneTavern’;

for both methods I have this error:

Error, Bad or missing expression for token: Scene, in ‘=’

References are OK, but seems that I can’t assign them in the script, but I can do it from the editor. There are some way to do from script? I need to indicate that the reference is an archetype or something similar?

Type of scene may clear the error

var archetype array<scene> Scenes;

Yeah, sorry, the forum removed the < and > signs because I didn’t use the code tag. I fixed it.

So, any solution to add archetype items to the array?

var() archetype array<scene> Scenes;
This creates an array of arrays
var archetype array<scene> Scenes;
Creates a single array;

Other than that I looked and you are doing the other part correctly

Both are the same, the () before var only makes the array visible in the editor in the actor properties, so you can edit items here directly.

I can add items from the editor, and spawn them in game. But I can’t add items from a function. So the array is working, but I do something wrong when adding from the function.

I’ve never tried adding something of class archetype to an array. But, so long as you’re careful about what you put in the array, you can use class actor. I think this should work.

var() array<actor> ActorArchetypes;

Removing “archetype” from the array declaration, gives the same error.

The array declaration is correct, I can add archetypes to the array in the editor, and later spawn them in game. All is working.

But the error is in the additem command. This don’t work:


I have copied one item added to the array from the editor and the actor reference is the same one I try to use in the additem command, but it gives error.

Also, this works correctly:

Default properties {
Scenes[0] = scene’TEST.SceneTavern’

But this way give error:

function Test()

Also, if I declare a simple var:

var archetype Scene SceneSomeItem;

and then I try to assign a value in a function:

function Test()
SceneSomeItem = scene’TEST.SceneTavern’;

Gives the same error. But if it’s assigned in default properties works correctly.

So I can’t manage archetype references directly, only in default properties and in the actor properties in Editor.

I don’t think the problem is with assigning an archetype to a variable. I’ll bet that the problem is assigning something of Class'Scene' to a variable.

If you start with

var() archetype array<object> ObjectArray;
ObjectArray.AddItem(SomeClass'Package.Resource'); // Any archetype that isn't a scene

does that work?

What are you trying to do with these scenes? I’ve never used a scene object before. How do you even create an archetype from something that isn’t a class ActorSubclass extends Actor placeable;?

No, it’s not working.

“Scene” is a custom class, extended from Actor. It’s a class to execute some simple cinematics. I want to have all of them in an array, so I can search them by tag, spawn it and perform the cinematic. I can use them in quests and others events easily.

Placing values in default properties works perfect:
Scenes[0] = scene.reference
Scenes[1] = …

but I can’t assign values from a function using Scene[index] = value, or using scenes.additem.

I don’t understand why. I had these problem before in others parts of the script, when trying to assign an archetype reference to simple variables. I had to use another variable and set it in the default properties instead using direct references.

I wonder if one reason why you’re having problems is because there’s also a scene class made by Epic:


// Scene - script exposed scene enums
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
class Scene extends Object

 * A priority for sorting scene elements by depth.
 * Elements with higher priority occlude elements with lower priority, disregarding distance.
enum ESceneDepthPriorityGroup
	// unreal ed background scene DGP
	// world scene DPG
	// foreground scene DPG
	// unreal ed scene DPG
	// after all scene rendering

/** Detail mode for primitive component rendering. */
enum EDetailMode

/** bits needed to store DPG value */
const SDPG_NumBits = 3;

There was a time I remember when I couldn’t set a variable to an archetype. I think in those places I had to use DynamicLoadObject. Maybe try this:

Scenes.AddItem(Scene(DynamicLoadObject('TEST.SceneTavern', class'Scene')));

Sorry for the confusion… my class is named “Escena”, in spanish, my language… but I wrote here translated to english, “Scene”.

With DynamicLoadObjet works fine, thanks. But I remember that to use DynamicLoadObjet, resources must be in a seekfree package, or something similar.

I remember having problems with arrays of archetypes… I hope this phrase is useful…
WHen i get to UDK a bit I will tell you if there is a way to do what you are trying to do. No garantues…