x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

https://www.youtube.com/watch?v=J7CIKkZvwgw

alt text

Product Version: Not Selected
Tags:
more ▼

asked Feb 23 '15 at 03:14 PM in Blueprint Scripting

avatar image

JamesPhoenix
6 4 6 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Feb 23 '15 at 03:26 PM

avatar image

Erasio
5.9k 291 86 293

avatar image JamesPhoenix Feb 23 '15 at 06:36 PM

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.

avatar image Erasio Feb 23 '15 at 06:43 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question