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.
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 messdisorganisation, yeah - kind of. Somewhat hard to read without seeing the whole thing.
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.
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.
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?
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
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.
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