Looks like you’re checking if the Overlapped Actor in the level is equal to a Blueprint from the Content Browser. They’re different.
I assume you want to check if the Overlapped Actor is of type BP_Zone?
If so, you need to use Cast to BP_Zone instead.
No no. The overlap actor is present inside the level.
And I am figuring out ways to not use Casting. It works with casting.
It also works when I do an equality check on the BP_Zone class.
When you select it from the drop down menu on the == node, it’s selecting the one from the Content Browser not the BP_Zone in the level. You can’t select something in the level from that drop down menu.
Ohh interesting. Why does it do that? And how to go around this issue?
Well, the character doesn’t know about the BP_Zone in the Level. You’ll need a reference to the BP_Zone in the Level.
Depends on what you’re using Other Actor for, but generally :
You’ll need to create a variable of type BP_Zone (Object Reference). Then you need to set that variable to the be the BP_Zone in the Level.
This can be done in couple of ways depending on how your character is spawned.
If the Character is already in the level, like you placed the character in the level,
- Set the variable you created to be Instance Editable
- In the Level select the Character, in the Details Panel, you can then set it to BP_Zone.
If you didn’t place the Character in the level, and is spawning it through the Game Mode and only have one BP_Zone,
- You can use the Get Actor of Class node on Begin play to grab a reference and set the variable. (Get Actor of Class is a bit expensive, don’t use it a lot)
If none of the above apply, you’ll have to look into using Blueprint Interfaces
Thanks so much. Will try and implement this!
So do I create this variable in the first person character BP or in the level BP?
First Person Character
Did you set the Zone Reference variable to the Zone reference in the level?
Makes more sense for the Zone to check for the character than the other way around, and then have that trigger the event.
When you do == object, you are testing against a specific object instance. Therefore, assigning a value from the drop-down doesn’t make any sense - you want to have some variable you compare against, not a “magic number” value.
When you do == class, it checks whether if the overlapped object is of certain class (or derived from it). Here, assining a drop-down value makes sense, as it’s comparing to something static.
Casting or including some class as a magic number (as a non-soft object reference) in the blueprint graph will both add the class to the memory when the class with the blueprint graph is present. You can size map the asset to see it for yourself.
When you want to avoid casting, is when you want to i.e trigger some generic behaviour that is shared between multiple classes. For that, there are delegates, interfaces, components etc.
I made the variable of the type BP_Zone and named it ZoneReference. I also made it instance editable. Then I selected my player start, and I couldn’t find my ZoneReference variable in that which I set to instance editable.
What does this mean? Can you please explain this?
Also, when I used == class, that worked fine as well.
Magic number is some value which is not a variable, just a direct value (i.e drop-down in the comparison node).
Whenever you reference something in the blueprint graph, as soon as that blueprint is added to a level, everything it references to will also be aded to the memory. Usually this does not matter, but it is something to be aware of. Soft object references don’t do this, but you need to handle loading them in manually.
If you right click your blueprit asset and choose size map, you can see a graph which shows the entire memory footprint of the class.