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’;
or
Scenes.additem(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?
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.
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.
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;?
“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.uc
//=============================================================================
// Scene - script exposed scene enums
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
//=============================================================================
class Scene extends Object
native(Scene);
/**
* 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
SDPG_UnrealEdBackground,
// world scene DPG
SDPG_World,
// foreground scene DPG
SDPG_Foreground,
// unreal ed scene DPG
SDPG_UnrealEdForeground,
// after all scene rendering
SDPG_PostProcess
};
/** Detail mode for primitive component rendering. */
enum EDetailMode
{
DM_Low,
DM_Medium,
DM_High,
};
/** 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:
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…