Problem casting a change to a boolean from another blueprint

Hey everyone,

For my final year project I’m trying to make a prototype for a Dodgeball first person shooter game. One of the mechanics I have in the game is the player being able to spawn a shield in front of themselves, to deflect shots off. However when the shield takes three hits, it is destroyed. I have tried to make it so that a player cannot spawn a shield if they have already summoned one, but regain the ability to spawn one, once their shield is destroyed.

My current way does not work. The casting itself works because the print I attached to it does appear, however it doesn’t edit the boolean. I know I am probably doing something silly but I just cannot see what is wrong.

Below is screenshots of my blueprints and a video showcasing the problem:

Ah right. Ok so you should not use “Get player character” in a multiplayer game. It will not return the right character reliably.

From what I see you have two very valid options.

  1. Get rid of the boolean and replace it with a variable of the shield. Like this you can on cast simply check if the shield variable is valid (once an actor is destroyed it’s invalid).
  2. Inside of your shield create a new variable of the type character. Make it editable and “Expose on Spawn”. When you create the shield you now have an additional pin to insert your player character into and can use that reference instead of the “Get Player Character” function.

I hope this helps.

Cheers.

Thanks for the fast reply!

I’m not 100% sure what you mean here. The spawn shield variable exists in my character blueprint, so adding the ‘mycharacter’ pin in there isn’t going to do anything for the casting from the shield blueprint.

I’m also not sure how a variable of the shield would work instead of the boolean, is there something in addition I would have to use?

I now know the problem is the ‘get player character’ node though so thank you.

Yes the shield variable exists. But that doesn’t help you changing a variable from your shield in your character does it?

You have your event hit on your shield actor. When it gets hit and has no HP left you want to change the boolean inside of the player character before being destroyed. You can not do that from your characters BP but need a reference to your character in your shield BP.

And the new character variable would fix this issue as you now have the correct character guaranteed. Whoever placed this shield you got him in that variable and can use that to set the boolean which will do it in the right one.

For the shield variable. No not really. It’s a simple actor reference. Just instead of checking the boolean you check “IsValid” for that actor reference. The upside is you can also check how much HP the shield has and do stuff with it rather than just knowing it’s up.

I hope that cleared it up a little.

Cheers