You have a link error in your code. Look at this line:
CompilerResultsLog: Error: OpenDoorC.cpp.obj : error LNK2019: unresolved external symbol “protected: void __cdecl UOpenDoorC::OpenDoor(void)” (?OpenDoor@UOpenDoorC@@IEAAXXZ) referenced in function “public: virtual void __cdecl UOpenDoorC::TickComponent(float,enum ELevelTick,struct FActorComponentTickFunction *)” (?TickComponent@UOpenDoorC@@UEAAXMW4ELevelTick@@PEAUFActorComponentTickFunction@@@Z)
I guess once you have a function (or not), UOpenDoorC::TickComponent which was removed but an actor was using it inside your scene. Here is what I’m doing in cases like this:
I delete everything in binaries folder, open the source file with an error, fix it, relaunch UE. If it still crashes, look for more errors (compile/link) in logs. Once you have fixed all the errors your build will pass and UE will not crash.
Please note that if you have removed a function that is used by an actor placed in the world, it way keep calling it, so You have to redefine that function, remove the actor, remove the function, replace the actor.
That’s the quick way that I’m solving that kind of problems, but there may be easier way.
Hi. thanks for the reply. can u tell me why do you delete binaries folder?
/*
Please note that if you have removed a function that is used by an actor placed in the world, it way keep calling it, so You have to redefine that function, remove the actor, remove the function, replace the actor.
*/
so u are saying that I have to correct my code after that build project start ue4 and delete actor and then remove?
thanks for the tip.
here are the cpp and h link text link text
Delete the bin folder, so unreal can rebuild it with corrected code. I don’t know why, but it does not check if the code is changed, and rebuild it. So you have to manually delete DLLs.
After look at your code I suppose you don’t need to do remove->correct>replace action.
i think there is a error. when i am trying to call getworld() in .h file, i think that ue4 has not created world yet…? someone told me to do that in the constuctor but i think it will crash again… (if i remove code (my code) from .h file it wont crash…)
I agree that the line in .h file may crash. You may try to do it in BeginPlay event. Anyway there might be many reasons why it crashes. The world does not exists, the Player Controller does not exists, i’m not sure. When writing C++ code you may need to check every pointer against nullptr, before using them. So you can move your code to constructor and write it this way
thanks for the answer and help… i fix that problem by moving GetWorld() and other functions in the begin play function… what do u think will it crash if i use GetWorld() and other functions in constructor?
Some objects like world may not be available during construction. When you drag an actor to the level, the constructor is executed. At that point engine is not ticking, there is no player, and I assume no world either. So in future use BeginPlay as kind of constructor, where some of the game objects are already created.
There are some other events/overridable functions available, that you may use for different reasons.
For full information you may read this documentation page.