Switching from Unity to Unreal, help updating scripts

Hey all! Very new here to Unreal. I’ve been using C++ for over a decade, but I’m having a hard time just understanding the workflow. I’m not sure the Unreal editor is getting my updated code once I save and build it in VS. I even tried things like closing everything, reopening, rebuilding, but sometimes I run my code and it’s still the previous version before my changes…

Even more weird: what I’m trying to do (also having trouble with) is just spawning an actor from the constructor of my derived APawn class. Once I drag it into the scene, I want the constructor to spawn an actor of APlayerController (unless I need to derive and spawn an actor of the derived class from APlayerController), but the editor immediately crashes once I dragged it into the scene. And when I try to reopen it, it immediately crashes again, even though I’ve taken that code out…

Any help is appreciated!

  • Leo

Make sure the code is built using ‘Development Editor’ (vs ‘Development’). And if you enable the ‘Live Coding’ you can keep compiling the C++ without restarting the UE provided code changes are in CPP only.

Thank you! That does seem to work. However, the Live Coding window crashes and not open anymore when I make certain changes. All I’m trying to do is spawn a APlayerController actor in the constructor of my derrive APawn class. I don’t think it’s related to that in particular though because it was crashing when I was just calling UE_LOG() to test when things changed in the editor.

It seems like I need to build in VS, then go the UE and press ctrl + alt + F11 to let live coding rebuild? Is that the process every time I change some code? What do I do when the Live Coding window crashes like that?

Probably the UE_LOG is the culprit…something like UE_LOG(“Calling bp %s from %d”, num)… whereas it expects two parameters which are String and Integer, but only integer is supplied. This crash has bit me many times.

Regarding the live editor… you only need to save the cpp file in VS and press Ctrl+Alt+F11. That’s all. If the changes include the header, then maybe you should exit the editor, compile c++ and then start back the editor.

Just a work of warning spawning actors should happen in a function outside of the constructor (in the sense of CDO)

Try spawning actors in BeginPlay onward. In the cdo you can instantiate components and hook them up but not spawn actors.