Casting is a bit weird at first, but think of it like casting an actor to play a ‘role’, the ‘role’ being your blueprint script. The role is the specific character acting out the script, and the actor is any blueprint actor.
Casting allows you to basically choose a specific actor, and then get details about that actor. You can control which you are doing through the input and outputs.
Let’s say you want to make it so when overlap with an enemy, this enemy gives you a certain value of credits, and you can set this value in the world. Make a Enemy blueprint, and create a variable, integer or float named CreditValue, and make it’s value 20, and click make it Editable. Make sure the enemy has a collision box. Now put some enemies in the world and, with each individual selected, give them a random value for CreditValue in the world (since you made it editable, you can do so on the right in the Details pane)
Now we will get that value from the player when we collide with the enemies collision box. We will do it using casting so we can get the specific values you set in the world.
With your main pawns static mesh selected, go to where you create new events, and create a new event Event Begin Overlap.
From this, drag off the Other Actor node, and search for == (actor). Click that. Make sure it’s connected to the top portion, and in the bottom portion, search for your blueprint ‘enemy’. Drag off the exist node, and search Cast To (enemy).
Connect that up. Now what this is doing is, when your main actor overlaps with something, it’s trying to cast the actor it overlapped to the role of ‘Blueprint’. Note that if the cast will fail if it is not == to Enemy, which is why we added that check. If it IS an enemy we are overlapping with, we will get the actor we overlapped with, and we will cast it to the role of enemy. Note that with casting, a blueprint can be the actor and the role. In this specific case, the actor from our overlap results is the actor we are casting, and we are casting to the role of ‘enemy’ - even though the actor is an ‘enemy’, I hope this makes sense. But this allows us to both get specific information from him, and have a way to choose a specific actor (in this case, the one we entered range and collided with).
Now that we have the cast done, let me explain it’s purpose. We now have the actor we collided with casted as an Enemy, and we know that we created the variable Credit Value on the Enemy. So drag off the ‘As Enemy Blueprint’ (or As Enemy? can’t remember specifically, the exit node for the cast) exit node, and search ‘get Credit Value’. Once you have that, right click and search Print String, and drag the exit node value from Get Credit Value into the text box, and make sure it’s all connected.
Now start your game. You should be able to walk next to an enemy and have the game print the value of the variable you created. More importantly, you did so by casting to an actor, and hopefully learned how it worked in the process. This isn’t the only way to cast, the beauty of casting is it allows you to get specific actors and tell them what to do, or get information from them, or change their information.
If that was too detailed, sorry, I tried to be thorough. If you still need help just ask 