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"

How do you get a variable from the level blueprint?


How do I get a certain variable (float) from the Level Blueprint?

Everytime my AI spawns, the Level Blueprint sets the variable 'EnemyAmount' ++1

But now I want my AI Blueprint to substract "1" from 'EnemyAmount' everytime one of my enemies (AI) dies:

... -> Destroy Actor -> Set 'EnemyAmount' (-1)

But the variable EnemyAmount isn't in the AI Blueprint and I can't reach it with 'Context Sensitive' unchecked.

Product Version: UE 4.9
more ▼

asked Nov 19 '15 at 06:46 PM in Blueprint Scripting

avatar image

11 4 8 8

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

1 answer: sort voted first

Why dont you set it in Game Instance or Game State BP's?

more ▼

answered Nov 19 '15 at 06:49 PM

avatar image

16.8k 671 167 677

avatar image SiraX Nov 19 '15 at 06:50 PM

I don't know what that means :c

avatar image Jacky Nov 19 '15 at 06:53 PM

Create the EnemyAmount variable in your Game Instance blueprint(create one in content browser if you dont have it already, and then set it as your game instance in Project Settings) Then you can get/set that variable from any other BP by Get Game Instance > Casto to yourgameinstance > Get/Set EnemyAmount.

avatar image SiraX Nov 20 '15 at 06:15 AM

Well, my gameinstance is already there but in c++, i only have a blueprint project. If i create a new gameinstance and use that, do i get errors?

avatar image Jacky Nov 20 '15 at 01:48 PM

You mean it is using the default game instance currently, i think? If thats the case then yeah, just create a new game instance BP in content browser, set is as your project's game instance in project settings and use that.

avatar image SiraX Nov 20 '15 at 05:24 PM

Thanks for your answer, but I have a not so important question:

If I use another GameInstance BP, doesn't that have a huge lack of functions? Because there already is one GI BP used.

Thank you again

EDIT: I noticed that I need a reference, do you know how I can refer to the gameinstance ? http://prntscr.com/94yo6m
I already have a Reference to my gameinstance but even if I use it, I need another reference or something like that

avatar image Jacky Nov 20 '15 at 05:37 PM

There wont be any difference between the empty default GI BP and the one you will create in the content browser. And yes, you'll only create the variables and use the game instance to pass those values between other BP's.

avatar image SiraX Nov 20 '15 at 05:44 PM

Could you answer my edit too. please?

avatar image Jacky Nov 20 '15 at 05:49 PM

Right click anywhere in the graph and then Get Game Instance > then drag from the blue pin and Cast to Yourgameinstance > and finally get/set your variable.

avatar image SiraX Nov 20 '15 at 05:51 PM

Thanks that worked. Do you know why my AI won't die sometimes even though the Health == 0 mark was hit?

Can it bug sometimes?

avatar image Jacky Nov 20 '15 at 05:54 PM

No idea. You should post a new question regarding that and make sure you provide some screenshots as well.

avatar image SiraX Nov 20 '15 at 05:57 PM

I think I got it but I don't know how it worked, I just connected the 'Destroy Actor' with the (if) AIHealth == 0 node.

Basically it's in the same function but it wasn't earlier... I don't know... somehow it worked

(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