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"

Widget Variable Counter

How to add to number every time another actor of class is destroyed by character's collision? I.E. starts at 0, when 5 actors are destroyed, number displays int 5

alt text

alt text

Product Version: UE 4.9
111111.png (228.3 kB)
22222.png (266.7 kB)
more ▼

asked Nov 02 '15 at 02:14 PM in Blueprint Scripting

avatar image

170 47 48 60

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

1 answer: sort voted first

Hello !

I recommend you to setup a blueprint interface that will contain a function like OnItemDestroyedByCharacterCollision, make your HUD inherit from this interface and act on the widget to set the correct value, and call the interface function from where you want.

Or, set this number anywhere else (in your custom game mode for example), and make the widget 'listen' the game mode variable using a binding on your counter.

more ▼

answered Nov 02 '15 at 02:29 PM

avatar image

928 32 27 50

avatar image nmm131 Nov 02 '15 at 07:23 PM

Can I do this inside a blueprintActor class, create a function called Destroy, set up a destroyActor to the function so the actor will be removed from the map. Then I set up on every instance of this, +1, and use a SET and plug that into the level blueprint SET number ? I just don't know how I can implement the +1 to variable int into the levelblueprint eventTick section to set the number to number + (variable +1)*#ofinstances

It would have to work like, number + this new variable --> SET number but I'm having trouble adding on destroy new variable + 1 to my function inside blueprintActor class

avatar image Begounet Nov 02 '15 at 07:36 PM

You can apply what I described previously in your level blueprint too I believe. I cannot check now but I think you can put an interface on your level blueprint. After that, you override the OnItemDestroyedByCharacterCollision function and set +1 on your variable in the level blueprint.

And for the item destroyed, there is an event called "EndPlay" that is triggered when an actor or a component is destroyed. If it can help you...

avatar image nmm131 Nov 02 '15 at 07:50 PM

I'm having trouble getting Variable into my level blueprint, to add with my preexisting value to display on my widget

alt text

asdfasdf.png (172.4 kB)
avatar image nmm131 Nov 02 '15 at 07:57 PM

If I do something like this inside the blueprintActor class, I still need to get the value into my level blueprint

alt text

aaaaaa.png (43.9 kB)
avatar image Begounet Nov 02 '15 at 08:11 PM

If you set your variable to stock the counter in your actor that is going to be destroyed, you will lose this value few time after (since the item has been destroyed). You have to set the variable in the level blueprint.

Here is some screenshots of what I recommend you to get the value in the level blueprint.

That is your blueprintActor An interface to allow the communication between blueprints easily How the level blueprint inherit from the interface and implement an event

If you don't know how to use interfaces, I recommend you to look at the documentation, that will explain more clearly than me.

myitembp.png (146.5 kB)
interface.png (71.1 kB)
levelbp_logic.png (183.7 kB)
avatar image nmm131 Nov 02 '15 at 10:41 PM

Got it to work! This was very useful. I will need to use interfaces more, it links the level blueprint and other blueprints easily. Thank you, very helpful.

avatar image Begounet Nov 02 '15 at 10:47 PM
  • Check if you correctly add the interface to your level blueprint, like in the last screenshot

  • Check if you compile your interface first

  • Recompile your level blueprint

  • Do File > Refresh All Nodes

  • Try again, it should appear

(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