Jump to content

Using PerObjectConfig with Actor classes spawned at runtime?


robojumper

Recommended Posts

I'm trying to use the perobjectconfig to read properties from a config file for actor classes.

 

If you want to read up on it, [this article](https://wiki.beyondunreal.com/Legacy:PerObjectConfig) sums it up pretty nicely.

 

Here's my class signature:

class ConfiguredActor extends Actor perobjectconfig config(ConfigFile);

Now I know that it works with non-actor classes, because I saw that this is how X2DataTemplate works. This is possible because you set the name that will be used to read config values using

local MyClass mci;
mci = new(None, "ThisIsMyName") class'MyClass';

This will set the 'Name' field of the instance to 'ThisIsMyName'.

 

This is all fine, but when I need to spawn an actor class, new doesn't work, because Actor classes have to be spawned, not new'd.

 

The function declaration of Spawn is as follows:

native noexport final function coerce actor Spawn
(
    class<actor>      SpawnClass,
    optional actor      SpawnOwner,
    optional name     SpawnTag,
    optional vector   SpawnLocation,
    optional rotator  SpawnRotation,
    optional Actor    ActorTemplate,
    optional bool      bNoCollisionFail,
    optional ETeam    SpawnTeam                 // FIRAXIS addition -tsmith
);

Now - where is the name I can use for objects? If I just Spawn() it, it will have a name such as ConfiguredActor_0, which can't produce reliable results.

 

It seems to not be possible to do with Actors what you can do with Objects. This doesn't make any sense since I expect something that works for a superclass to also work for a subclass, so am I missing something?

 

I hope that anyone in here has experience with UnrealScript and can help me. A possible workaround would be externalizing the config into an object class which then gets read by the actor class itself, but that can't be it I think :wink:.

Edited by robojumper
Link to comment
Share on other sites

Since the new call is buried inside spawn for actors I'm afraid you may be out of luck, unless there is some alternative to spawn that lets you pass in an instance name that it'll respect, but I'm not aware of any such thing.

 

So I think your workaround might be the only viable option here.

Link to comment
Share on other sites

  • 4 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...