Cant change variable in another blueprint

I have a problem with setting an boolean variable in one blueprint from another blueprint.

In my Bp_arrow blueprint i have created an variable called “starting” which from the start is “false”

In another blueprint called “Ranger” i want to change that variable from false to true. I have tried to cast it and then set the variable as true. But it keeps failing the casting.

I have also tried to use “Get all actors of Class” with either “get” or “ForEachLoop” but it doesnt change the variable from false to true.

sometimes i get an error “Accessed none from” which makes me thinks it empty or something. how can i change this?

I hope someone can help me fix this.

Hello XS_Bart!

I can try to help you, but I need some more information.

  1. Do you spawn “BP_arrow” into your gameworld at some point?
  2. What type of blueprint is “Ranger” (actor, pawn, character … etc)?

I am assuming you are using blueprint classes for this and not level blueprint?

I don’t know what you know about blueprint communication, but generally speaking the blueprints you want to communicate with each other MUST exist as Instances of your class in your game world for this to work. Otherwise you will not be able to set up references which again could lead to the Accessed None error message.

Understanding the concept of Casting and Classes are also helpful here.

1. Do you spawn “BP_arrow” into your gameworld at some point?

Yes, when i fire an arrow from my bow, i spawn the BP_Arrow blueprint.

What type of blueprint is “Ranger” (actor, pawn, character … etc)?

my Ranger is a TriggerBox blueprint (Its a create widget triggerbox, just to show some text on the screen and change a variable)

I am assuming you are using blueprint classes for this and not level blueprint?

Yes im trying to do this from blueprint classes and not the level blueprint.

my BP_arrow blueprint is an actor class

I know that if i will try and change a variable in my character blueprint, i can just cast to that blueprint and from object i just drag out and pick “Get player character” and that would work.
But i cant seem to wrap my head around how it works with an actor and triggerbox.
When i cast from Ranger Triggerbox to my BP_Arrow actor, what would the object from the “cast to” node, be. Should i just drag it up to “other actor” from my "OnComponentEndOverlap?

The object pin on the casting node should be a reference to the blueprint you want to communicate with. In this case that would be the BP_arrow, but if you try to communicate with the arrow BEFORE it is spawned it will always fail because the arrow does not exist yet. I think I would try to reverse the communication somehow and have the arrow initiate it when it is spawned.

I have to do some more testing before I can give you a more detailed answer.

EDIT: Oh and I forgot to tell you that the reason casting to the player character always works is because the player always exist when you play.

I’d like to clarify something. It sounds like you’re trying to communicate with BP_Arrow before it’s spawned. If that’s the case, then I’d definitely follow Fjellgnu’s suggestion of having the Arrow initiate at spawn.

If not, prior to setting the bool add an “Is Valid” node could be used to verify that the arrow exists. That should alleviate the “Accessed None” error when prompting the change before the arrow actor is spawned.