So I’ve created a maze game where the player has to collect items. Once all items are collected, the game ends and takes the player back to the main menu. I want to change this to expand the level. I want to be able to destroy one of the walls of the maze and extend the level in that direction when the player collected the desired amount of objects. I created a Blueprint class called BP_SecretController, and attached the desired wall to it and put it in the game world. Where the C++ code used to load the main menu, I instead have created code to try to destroy the object, but it is not working. I’m not sure that I am referencing the object correctly. In the game world, the object is called BP_SecretController2. Below is the code:
Gam312_FinalGameModeBase.cpp:
if (Score >= 12.0f)
{
BP_SecretController2->DestroyComponent();
}
You can, also, try spawning this actor from inside your GameMode class, and then storing the resulting actorreference or access it’s component and store it.
So, make sure the reference is not empty by finding a way to store the actor’s reference before calling it.