Accessing "none" casting to actor class

No compile error, however when i’m testing i receive that it’s accessing none, as far as i know my casts are set properly if anyone knows a better way to go about this or any suggestions i would really appreciate it. thanks all.

Hey There Nejibana!

The failure is occurring because The For Each loop has the completed pin, bypassing the If/Branch test, so the Equp node is still trying to get something from the input pin, for the target, when it fails to get anything (i.e. null), it’s complaining about it. So either the Get All Actors of Class, is producing nothing, or there are No Tags, as your checking to see if the actor has a tag with the node Actor Has Tag, and feeding the boolean value into the IF/Branch. But the completed pin, bypasses all of that, hence the “null” value, and the message being produced.

Hope this helps,

Inc.

Have you verified, that your actually getting any actors back in the array? Between the Get All Actors, and the For Each Loop, put in a print node, dragging off the Get All Actors array a Length node, so that you can at least see if there is any actors being returned at all.

Yes you probably did get the same error, because of the Actor has Tag node is going to pull from the For Each loop as well, and get nothing, this is probably ocurring when the Completed pin fires on the for each.

I really would check that you are actually getting actors back, and I would not pin the Completed Exec Pin to anything, unless you just want to set it up with a return node. The completed pin, is bypassing all your validation testing for the tag. Hence when the completed fires, you really don’t know what your attaching too, and in this case it’s a “null”.

In terms of attaching a skeletal mesh to a socket, you have the click event that has occurred, you really just need the reference to the actor, so long as you can determine the object to attach, and the socket to attach to from the click.

Inc.

Hey there ,

Thanks for the prompt response, I attempted to feed the completed exec pin into the branch and i got the errors provided with the attachment. However, I fed it into the cast to function for the actor reference and it cleared up the errors however my end result isn’t being achieved. Am I going about trying to equip a skeletal mesh to a socket the right way? I feel like there is something simple that i’m just overlooking, been at this for days now. xD

So I pulled the data from my items structure and it seems to be finding child blueprints just fine as it’s printing the name. I even attempted to change the custom event JUST to the blueprint for the short sword without pulling from the struct and i’m getting nothing.

and as you suggested, i killed the completed exec

When you killed the completed exec, did the error message stop?

Now, go ahead, instead of dumping out the object name for the sword, drag off another pin from the Array on the Get Actors, and wire that to a Length node for the array, and wire that into the Print String, then wire the print string back to the for each loop so it executes, and put another print string, over there feeding into it,the Boolean value for the get actor tag nodes, and let’s see what that turns up.

Ok, this is wired a bit differently than I wanted.

Bring the Exec Wire from the Get All Actors of Class, straight down to the print string node, withe the length value wired into it, then bring the Out Exec Pin back up to the For Each Loop, and then wire the For Each Loop back to your Cast. Such that we have all the original logic, minus the Completed.

Bah nothing to be sorry about. So we are not getting any actors, which is why the error message was originally occurring due to a null reference caused by the Completed pin bypassing your checks.

So at least that much is known. (Either that or the first If/Branch is failing because it cannot be equipped, but I think you knocked that out, when you did the display, and got the short sword)

Yet, with that out of the way. Now back not to an error, but what you wanted to actually accomplish.

Which I’m assuming the following.

  1. Player clicks on button
  2. Button fires
  3. Your blueprint is invoked
  4. You check to see if the item can be equpped
  5. If true, then proceed, else false, and go do something else.
  6. Then we are getting all actors of class, Master Inventory

BUT

Aren’t you wanting to just take the Short sword Mesh, and attach it to the Socket, so the player can start hacking and slashing?

If so, then only really need the reference to the character, so you can do an attach of the short sword, to the socket. I.E. this attach will need both, Actor/Component, and the Socket name for the Attach blueprint node.

Or have I missed something?

Inc.

You were right, I plugged that in and the print string returned nothing. Which is making me scratch my head harder now, because the struct says it does.

93401-2.png

also, yes the error message was eliminated when disconnected or plugged into the cast to the master item itself. Considering the tags I’ll leave it disconnected

Nothing off the tag either it seems

sorry about that, and sorry for the mess, but i rerouted as you suggested, the print return stated “0”

More or less you’ve struck the nail on the head. I’ve managed to equip the skeletal mesh simply by attaching it on construct. However, I’m going for a more dynamic approach so that way if i have a different weapon i want equipped off the same master blueprint it can be changed at will via a button. So this way i’m not:

Equipping it on actor overlap
or being stuck to a singular skeletal mesh

Oh one other thing, you might want to turn on the Arrows for the “wires”, much easier for you to see what is going on, when you come back to the blueprint 3 months from now, without having to mess around with all those reroute nodes.

To do so

  1. Click on Edit
  2. Click on Editor Preferences
  3. Click on Blueprint Editor under Content Editors
  4. Then check the box, for Draw Midpoint Arrows, it’s the first item

Inc.

Ok, I understand why you wish to be dynamic, I"m totally against hard coding anything. It’s harder to be completely dynamic, but in the long run, it always pays off.

(It’s why I put in the code for , to be able to change parameter values for materials at will. I mean why bother with a Material Instance, heck, just get a dynamic material instance and go, less files, less download, less build time, less everything.)

But anyway,

So all you really need to have, is access to the actor, so that you can know, the actor, and then probably via a table, the name of the socket to attach the weapon too (i.e. much easier to maintain the socket names in a single table, instead of chasing that name down all over the place, or at least the name assigned to a variable)

Ok, totally understand, so where is your reference to the Actor that clicked on the Button? Because after you do the check, of can the sword be attached, all you really need is the player, and your off and running.

So perhaps I’m missing something (probably am, because I’m not sure why your checking the Tags), But as you already know, that you have the short sword, and that it’s allowed (we know this because we got to the All Actors of Class), then unless the Tag is really important, you should be able to just invoke Equp, which has the 3rd person character, and can get the skeletal mesh (or just pass the mesh to equip, as your only using one socket name),and your off and running.

Or perhaps I’ve simplified this too much.

Heck, I haven’t even bothered with more than 1 socket yet. I mean yeah i COULD if i wanted to, but during this trial phase that would just over-complicate the test of the blueprint to see if it would actually work. There’s 1 socket, a master item BP, a master weapon BP, a Master Sword BP, then the actual short sword BP which is essentially a test dummy at this point just for giggles to see if the parent-child chain would function. Still scratching my head… I think unreal has a bit more fine tuning needed on casting, if it were as simple as tossing around +variable i could do this all day.

That check actually comes from a custom event in the master item bp, cast to the char, and get socket of the “as 3rd per char”