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 to cast actor blueprint in level blueprint ?

i want to make that, if all bottles are destroy then level will complete in given time with bottle count variable. so how to cast actor blueprint in level blueprint

alt text Bottle actor blueprint -> alt text level blueprint -> alt text

Product Version: UE 4.18
more ▼

asked Mar 24 '19 at 08:21 AM in Blueprint Scripting

avatar image

1 1 3

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

2 answers: sort voted first

Casting is not a method of communication - it's testing whether an object is of specific type and then treating it like so.

If you placed the bottles in the level, there's no need to cast at all. Just drag & drop bottle actors' references into the Level Blueprint from the World Outliner. Have the LB count and destroy the bottles.

more ▼

answered Mar 24 '19 at 09:52 AM

avatar image

15.2k 77 25 62

avatar image Nebula Games Inc Mar 24 '19 at 06:00 PM

As the above answer states, you just need references to your bottle actors in the level BP, that is one thing it is quite handy for. If you need to communicate with the level BP which I think is what you might be asking for by asking how to "cast to" you are looking for an event dispatcher. That will allow you to fire off events in the level BP when things happen in world actors like your bottles. If you need help with casting, references or event dispatchers check out videos #1, 25 and 26.


avatar image VIROH Mar 25 '19 at 08:39 AM

This is what you are telling me ? alt text

screenshot-199.png (206.1 kB)
avatar image Nebula Games Inc Mar 25 '19 at 12:45 PM

Yes, except you don't need the cast node, the level blueprint creates a direct reference. And you don't need to use the game instance if you want the variable to reset each level. The level blueprint is fine for that. But you may want to consider putting this script into an actor you can place in each level, this way you don't have to repeat the code in each level blueprint.

avatar image VIROH Mar 25 '19 at 01:23 PM

Like this?alt text

screenshot-202.png (194.7 kB)
avatar image Nebula Games Inc Mar 25 '19 at 01:43 PM

Exactly. The cast was unnecessary.

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

for the purpose you are trying to achieve casting the actor blueprint in level is not optimal, instead you could use a game instance to set the number of bottles you have destroyed and check in the level blueprint if the number is equal to the number of bottles in level.

you can learn to use game instances from here:UE4 - Tutorial - Game Instances

more ▼

answered Mar 25 '19 at 09:42 AM

avatar image

23 3 1 6

avatar image VIROH Mar 25 '19 at 12:09 PM

I did it but their is a problem ,when ever i am going to next level or restart current level the game instance variable stored previous value. so, how to reset it when i quit or complete current level or restart my level. Level blueprint -> alt text Actor blueprint -> alt text

screenshot-200.png (200.5 kB)
screenshot-201.png (230.8 kB)
avatar image jaydave Mar 25 '19 at 04:53 PM

I guess that you need the instance variable for one map and as soon as the level is complete the bottle count should be set to zero, if so then you can reset the bottlecount as soon as your level is completed(when all 12 bottles are destroyed ) in this way in your new level you will have a fresh bottle count

(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