What to do if one Node is not passing to another

Hello. I made a piece of code, which for some reason is not passing through to the other nodes of the could what are ways to test what is wrong, for it gives no errors. I am new to this problem and not sure what to do::

Put a print here to see what the value actually is

Ok , So it keeps coming up with the parent instead of switching to the children…This was my problem when trying this with a enum to set the type of resource, but it kept going to the parent and not considering the children at all. What do you do if or some reason ue4 keeps defaulting to the parent? UPDATE: So I added it to the list and they still don’t drop off the resource… Going to keep looking. --Update 2: So Unhooked the switch on string and just made it straight and it added the resource for some reason the switch on string is tripping it up…What could be done to help this code see the children so I can change which resource they are collecting.

What kind of parent and child?

What I did is I made the Resource patent (ResourceBase), a Actor, and Made the Child Actors (ResourceWood, ResourceMetal, etc. ) as well. In ResourceBase I made a Enum which was meant to determine what kind of Resource the Worker Unit was suppose to carry. But for some reason the when trying to set it up to change between the resources, the code would always default to ResourceBase’s Value and Not read the values I set for each child of Resource Base. So they resource would always be what the parent was set to, so even when collecting wood I was getting metal instead. So after many attempts at making that work I started looking into other Templates code, I saw the Switch on string hoping that maybe be it would see the name, and seeing it is something other then parent, it would switch to the values from the names of each item, but it seems that the switch is stopping the units from giving the resource.

Ok, I just tried it with GetClass and I get the child name, not the parent. How are you setting ResourceBase?

How I was setting Resource Base’s Enum I made it a variable called "Resource Type "and I choose Metal out of the list. But if you mean Setting Resource base as Set Resource Base in the Worker Blueprint I have not set it but I just did “Get Resource Base” I am trying to Set it and I see the Child and Resource come up. Should I set it and then have the values Run through those?

Right. You shouldn’t have a class type variable there, try switching on

It’s a switch on this

Here was the first bit of code I had before trying the Switch by String method:
Player Controller:


Player Controller:

I don’t think you need a blueprint for each resource type. You already have the resource type in the parent BP. That’s it, you’re done.

I will give it a go, will update you later today after work.

You CAN have a BP for each resource type, but I don’t think you need it. Surely having the parent and setting the mesh and resource_type variable does it?

In any event, you need to looking at the resource type variable in the blueprint for that switch, not the name of the class :slight_smile:

If you want to know if you can pick something up:

It crossed my mind actually what you’re trying to do here…

Yes, it IS worth making a child BP and setting the default type to brass ( or whatever ), and changing the mesh etc. What you get from this, is you can just drag one of these into the level ( or spawn ), and it’s automatically brass without you having to do anything.

But later, if you have a variable of the parent class, I think you probably still need to switch on the enum variable in there.

Maybe you’ve seen this sort of thing

But you’re always going to get the parent class back.

Yes That what I have been going through, I am just trying to get the children to be noticed sadly it has just not been working :frowning: . I am Trying to get it but parent class keeps coming back. Ok So with the Example shown here, they get the Class the Actor Parent, then they get the Display Names, get the child’s name, but then cast to the Parent Class correct?

I don’t think it’s ever going to work.

The variable has to parent class, otherwise you can’t assign objects to it and think of using a switch. But then, whup, it’s the parent class, and that’s what you get back.

Like I say, do the switch on the variable inside.

Ah! This does work

So you need an actor type reference, then you can switch on string.

The only problem is, if Epic decide to later change the way class names are displayed. Then you’re f**cked.

A switch that looks at the enum will always work.

1 Like

Ok, when looking at everything this morning I looked at a verison of making this RTS where the Resources worked (That was on a Blackboard (was following Ryan Laley’s RTS Tutorial : Unreal Engine 4 Tutorial - RTS Part 13: Collecting Wood - YouTube, but sadly the combat system got in the way of what I was aiming for with my RTS.) So I tried to follow the coded and got a result where it does collect but for some reason thinks the Resource base Variable has None in it, and does not record what it is collecting.

Also Updated the Resource Bar to show the new Updates:

Totally different problem. What’s setting this?

In the Code it is a normal Actor, when that is a stand in for the Resource Base in the player controller, (it was part for the original tutorial I was following RTS Game - Resource Collection - YouTube) but here I was hoping to set the Resource Base with it in hopes that the game would stop complaining about it Accessed Nothing.

Here is where it was set: