Get actor of class not returning an actor?

Simply put, I have a set actor inside of a class param and when using ‘Get Actor of Class’ it returns ‘none’.

If get actor of class returns none, you don’t have an actor of that class…

What are you doing after calling it? Can you show a bit of code?

GetactorofClass1
GetactorofClass2

Try printing what you get, I never trust the debugger… :slight_smile:

Does ‘GetActorofClass’ Require a spawned actor or can it still be referenced in memory?

Ah - no, you need a spawned actor, that’s what it’s getting…

It doesn’t need to be spawned, just in the level etc. If it’s a widget, in memory. But you need an instance of the actor.

2 Likes

AHHHHH Okay!
I am working on a shop system. So far it worked just fine until I tried to add another object to my list of ‘Purchasable items’.
Is there a module that can simply create a temporary instance of an actor in memory?

here is my entire BP


Im using a data table to set actors to class references. Then im grabbing the actor reference and setting it as a “Traced” actor. Then continuing from there. Again, so far it has worked with every other item. But the new one I created (which doesnt have ANY instanced items yet) doesnt work.

If you have the class, you can:

More info:

2 Likes

Thank you ! I was able to fix it by spawning in the actor needed from the class when being used. Then setting the actor to hidden in-game. When the actor is no longer needed, the spawned instance is destroyed!

This is my fix for now however, reading into soft references seems like the MUCH better way to go. I’ll need to update my blueprint to use these. Especially when spawning/destroying 100+ hard object references at a time… it’d be much more efficient to load in just the bit of info I need.

You can use a class for this as is - no need to spawn an object.

Soft Class Reference makes it more performant in some scenarios - when you’re dealing with a lot of classes and you do not know if you need them or not.

Good luck!

1 Like