How to add Multiple Levels and Widget?

Ignore this problem for now.

Ok I know how to add levels and widgets. What I’m trying to do is, when I click on Play it should show a widgets showing “New Game” and “Quit”.

Aim: When I click on “New Game” it should start my character running and load everything that I implemented in the level. And when character die it should show the Widget “Restart” or “Quit”?

What I did: Create a new Empty Level called “StartMenu” and widget with “New Game” and “Quit” options. When user or me Click on New Game it loads a new Level called “Runner”. So good far now.

Problem: It is auto run endless runner game. When I open “StartMenu” Level. It display my character is falling and background. And then everything is dark because it is empty level. How to solve it?

I’m not good in explanation. But in short I want to create a Menu>Load New Level> Restart Level (On Death).

Is implementing multiple widgets in new empty level is good idea? Or is there better solution what I want to implement?

Edit: Ok. Problem was Game Mode. I was generating tiles/floor inside Game Mode Blueprint. I copied paste everything from game mode to level print. :slight_smile:

Ok, a little tired so not great answer.

I can not find it right now, but remember that the tiles are deleted from behind the player so there are not a million of them. Put a BOOL up and when dies, stop that function happening. As I can not find the code I am sure a bool will work, but that is your issue.

I will see if I can find where it is done again.

Found it

I was spawning floors through “Game Mode” but now I’m spawning via level blueprint. So that they don’t clash.

I have a function in Level Blueprint called “AddFloorTile”. I want to call this function in Blueprint Class called “BP_FloorTile”. Because in BP_FloorTile there is an End Trigger when player overlaps it and should call “AddFloorTile” Function from level print and delete current floor after 2 seconds.

Can u please tell me how to call level function in blueprint class?

And this screenshot was uploaded by me (99% sure) because Im using same functions.

I’m searching on Internet from last few hours but no success.
Can you show me how to do it?

I found one solution here:

But its not working for me. :frowning:

Hi ,

Can u please tell me how to call level function in blueprint class?

The only way I know, is call the BP in the Level, and send the data that way

I do it differently, not perfect, but works.

What is most difficult thing for me while working on UE4? Casting.
I have spent 3 weeks but can’t understand this “” thing. :frowning:

I tried similar way but Casting failed. :frowning:
Please tell me what should I do here and also refer me some Casting Tutorials.

In the beginning I’m spawning 4 tiles. And after that

Overlap End Trigger at the end of tile > Delete Last Tile > Spawn One More tile.

With your pic, why are you running a loop?

Why do you need to cast the same 3 times?

Just curious

OK

Store them in a Array when you spawn.

Then in Get you can grab the one you want.

Here is a quick example, sorry for the Purple lines I am just use First Person Actor, that is all for example.

I already did this. “FloorTiles_Manual_Test” contains all different floor tiles.

But problem is casting here. In my last screenshot I dont know how to cast “BP_FloorTile”. I don’t know how to set thing.

Might of been a bad example.

Ok, If you know what tile is next to be deleted, then you do not need a loop.

Run one function to spawn, and then get the array number of the next to be deleted and delete them.

You are only running 4, for doing it without loop would not be that bad.

So you are looping to spawn?

P.s. 1:44 am here

I’m not doing loop again and again. Just first . So it not big deal.

By the way, here my problem is related to casting. Will you please temme how to cast my “BP_FloorTile”? It’s 9PM here and before I go to bed I want to make sure that I did something new today.

To start with, why is your cast already named?

Would you not start with a blank one and add a result from an array

hehehe… then u should help me before you go to your bed.

I’m looping to spawn 4 tiles in starting. Nothing else. After generating 4 tiles I’m not calling loop again.

Just reach end point of tile, there is invisible “Box Collision” which trigger and add one more tile and delete last one. In this way there are always 4 tiles present in level.

And , you always give good solutions and if I designed my little buggy game and it just because of you. U always helped me. We can discuss this loop later in some new thread. But right now Im here asking about casting.

And from last one hour you are just discussing about loop.

I think now you can help me.

Here’s a very simple rundown on what casting is so you can understand the concept and start developing complex concepts with it:

When you create a blueprint, it’s like an unborn framework for any objects you create with it. You’ve created their look and behavior, but they’re still unborn.

When you place a blueprint in a level, or spawn it with another blueprint, you’re giving birth to a particular copy of that blueprint. This is called an instance. It’s alive and ready to go.

If you put BallBP into the level twice, you’ll have BallBP1 and BallBP2. They use the same structure, but are separate and individual entities. For simple actors like these, you can simply cast to them with a reference of their particular instance, with something like a levelBP reference, Get All Actors of class, Overlap results, etc.

Cast inputs are necessary because blueprints usually rely on something else to function.

Sometimes you even have a situation where you need to cast to component of a larger system. An AnimBP, for example, is only created when a character is in the world that uses that AnimBP for its animations. When that character enters the world, it creates its own instance of that AnimBP to use; otherwise, all characters using it would always be doing the exact same thing.

So for casting to something like that:

Get Player Pawn > Cast to [playerBP] > Get Skeletal Mesh > Get Anim Instance > Cast to [animBP].

And then you have situations where you need to change the physics on an actor. Since physics exist per component of an actor, you have to cast to a particular component (usually the root). You would have to give it info on what component it is, and what actor instance it’s coming from. So that’d be something like:

[get actor instance] > Cast to Actor > Get Root Component > Cast to Primitive Component.

So, in summary, you have to be thinking about the instance of the actor in question and what info the casting needs to properly communicate with it.