Struggling to get specific information on an actor

I have an actor that has an enum in it to identify 2 versions of the same actor. They both have a variable in it to add to an overall count when interacted with. Version 1 would add 3 to the overall count, whereas version 2 would add 5 to the overall count. I set the enum in the construction script of the actor to set the version I want. I’m trying to call the actor from within another actor with the “get actor of class” to get the different versions and increment my count depending on the type; however it seems as though it is only ever using one of my two versions and I can’t seem to figure out why.

I apologize in advance for the disorganization. I’ve been trying to fix this issue for a while now and so I haven’t had the time to reorganize and clean things up.

Here is where I am trying to get the enum from my actor, and depending on the enum, either add 3 or 5 respectively; however it only ever adds 5.

Same screenshot as above (way messier, I apologize) I am also now taking the name assigned to the different enum versions and printing it to test what version it is taking, however both enum branches return the same value “wood” even though in the other actor, I define the name in the construction script

I’m not entirely sure this is related or helpful, but in that same construction script I also change the static mesh, which is working as intended in game. I’m more than happy to share any additional information that may be useful, just not entirely sure where I’m messing up at or how to go about fixing it, any help is appreciated

How many Resource Node actors are there in the game at the time this is executed? The Get Actor of Class blueprint node finds the 1st one it can (whatever that means). Perhaps it’s not the actor you think it is. You can only use this node reliably if there is a single instance in the world.

If you have 3 Resource Nodes the Get Actor of Class call will return one of them, but you can’t be sure which one.

Also, it seems you’re calling the Unit Move Command from the very actor that implements the interface - is this intentional?

When it comes to the spaghetti mess disorganisation, yeah - kind of. Somewhat hard to read without seeing the whole thing.

There are multiple at the time of execution, so that would explain the issue that I’m having. Would it be better to add them to an array and cycle through them to read info on a case by case basis?

The unit move command call is intentional, as if it’s not an interaction with a resource node then the player moves to the location as a standard action

Lastly I do apologize for making it hard to read, I’ll try to clean things up and make some adjustments and see if I can get it to work. Thank you so much for your help either way!

I’m now trying to use the get all actors of class node so I can just get everything, but I’m struggling to figure out how to filter through the array to find the specific node that my character is interacting with. I feel like the solution is so simple yet I’m just banging my head against the wall trying to figure it out

How do you interacting with your actor? Do you use some kind of aiming to actor and “Press key to interact”? If so, you can use a Linetrace to find out exact actor you interacts and, after that, just cast Actor class to YouActor class, so, if cast succed, you’ll be able to access variables from this actor, including you enum type variable.
And, I noticed, you have some actors of resources (stone and wood), which behaves differently depending on their type, but have a fundamental similarity (both are resources). I just want to give an advice about organising your blueprints: use class inheritance (OOP programming feature), create a base class (name it, for example, “Resources”), after that create some variables and functions inside base class, make child classes (“Stone” and “Wood”, like your enum types) and set specific values and override functions in each child. Maybe it’s seems harder than single enum variable, if you don’t have any programming experience, but, if you managed to understand it, you’ll make your blueprints cleaner (easier to read) and be able to easily add new resouces to your game in the future.

1 Like

It’s a top down camera angle, but in theory I can still cast a line trace out from the actor in theory right? And yeah doing the parent/child would have been way easier in hindsight for the resource blueprint. At the moment I don’t plan on having any additional resources and I was hoping to not have to go back and redo everything to create a parent/child but I may end up trying that anyways if I can’t get this to work

You’re right, you just need to find Start (camera position) and End (somehow get interacted location in world space) trace location and set some other parameters as a TraceChannes, Ignored Actors and etc.
But, maybe you don’t need it: I don’t know, where you call this event and what do you pass as an arguments to this event. Maybe you have already got a reference of required actor and can just use it. It’s hard to say without knowing full interaction process.

1 Like

I still can’t figure it out unfortunately, and I appreciate your help. I understand that it’s hard with limited information and I’m more than willing to share whatever is needed to help understand the situation better, I’m just honestly not sure what all is relevant or not in this case. I’m still very new to everything so sorry for making things so difficult

Perhaps you could tell us what is going on in the game:

  • it’s a top down RTS like situation, right?
  • lil’ dudes are zooming about collecting wood, stone and whatnots?
  • what triggers the calls above?
  • what is happening to whom, instigated by which entity?
    – the player selects a resource node with the mouse and specific units dash to it?
    – a unit scans the ground to find out the types of nodes hidden underneath?
    – you click a button on the interface in order to transfer resources from one inventory container to another

In short: how do you know which resource node is needed at the time of execution?

Do tell.

Everynone already mentioned this but I want to re-emphasize it:

Get Actor of Class is most likely always returning the same Resource Node actor, i.e. the first actor of that type that Unreal finds in your level. In this case it’s a Wood Resource Node. Because of that, it’s ResourceEnum is always the same also. So it will always ever add 5.

It seems your issue then is how to get the correct Resource Node actor that is relevant in the situation in the blueprint code where you want to query its enum.

You should not be using Get Actor of Class node in this case. Maybe you rather want to use Get All Actors of Class, and then loop through them all and add all their resources to the player’s inventory?

Yes, it’s an RTS, inspired by Starcraft and Warcraft III

I have a worker unit which is a child of my parent unit class, which handles unit selection and movement. The worker unit has extra in the event graph to handle an event when I right click a resource node. So the typical right click will send a movement command, unless it’s a resource node, in which case it will tell the worker to move to the node, mine it, and return it to the closest dropoff building.

Attatched is a short youtube video to go through some of the blueprints and a small bit of gameplay to show functionality. At the end it’s not completing the dropoff because it’s not hooked up currently, as I’m trying to identify the exact resource node that is being interacted with so I can determine if the worker is mining wood or stone, to increment the overall resource amount appropriately.

I am using the get all actors of class node now as it will cycle through all available, but I’m struggling to figure out how exactly to filter that array to find the exact node that is being interacted with by the worker. I feel like if I can find a way to filter the array to get the node being mined then it would fix my issues

Here are three more screenshots, this is what is going on when the worker is first told to mine a resource, as opposed to finishing and dropping off, if it’s helpful at all

as I’m trying to identify the exact resource node that is being interacted with so I can determine if the worker is mining wood or stone, to increment the overall resource amount appropriately.

You have a couple of choices here:

  • you can obtain the reference of the clicked actor from the right click
  • you can have the unit detect the node with an overlap

Ideally, you’d do both:

  • right click the node → send that resource actor’s reference to the units that need to perform the operation, along with the Move Command
  • have the unit detect the resource actor with an overlap and compare it with the reference sent before (so they can start interacting with the correct one)
  • start collecting from this node if the references match

A bit crude (due to time constraints) but the idea could be:

  • there are 2 actors classes in the example - aUnit and aResource:

  • the interface that takes an actor and a location:


  • the player controller handling clicks:

– LMB to select the Unit
– RMB check what’s under the cursor and, if it’s a resource node, sends it to the Unit
– if the RMB did not connect with a node, send just the location, we’re just moving

The casting can (and should - here only to demo) be replaced with a better interface and / or inheritance and collision channels.

  • the Unit:

They go where they’re told and check if the actor’s reference match when they bump into something. Again, this can be handled much more gracefully. Just the gist.

You could do it without the overlap checks but it’s a good habit the target actor is still there when we arrive - it could also be done as a singular check on arrival.

Hoping you could work it into your existing system. After that, you may want to establish an additional ID system - kind of depends on how complicated things are supposed to get. It often gets out of hand. :innocent:


Wow @Everynone you’re really going out of your way for that answer :muscle:

YES! I finally got it working!! Thank you so much for all the help, like Ari said, really above and beyond and I cannot tell you how much I appreciate the help on this, I can finally make some more progress, and I feel like I learned a lot in the process, so thank you again for your time, patience, and understanding. Really means a lot

1 Like