Did you manage to finish the refactor yourself? What were your challenges?
No major problems, actually had done quite a bit of it a few vids back when I misunderstood how far we were meant to go with one of the challenges!
What it did for me was relieve (to some degree) anxiety I was having that I was understanding things as I went, but loosing track of the wider picture to the point that I wouldn’t know where to start when creating my own game. Being forced to review a lot of it really helped remind me of the steps needed to set things up in the first place, though of course the lesson in refractoring in itself is also very helpful.
I had a very big bad issue here: when openening the TankPlayerControlerBP it crash the unreal editor.
The funny thing was that the game was still able to run .
Tanks to the debugger (attached to the editor) I finaly found the explanation : the error was from ATankPlayerController::AimTowardCrosshair(). The first thing to be done there is to GetPawn().
This methode is called on evry tick, and it’s seems that it’s called before the game is actualy started. Calling it before the game is started return a null : so doing
`UTankAimingComponent* tankAimingComp = GetPawn()->FindComponentByClass<UTankAimingComponent>();`
result in a null pointer exception. The fix : just verify that the pawn is not null (easy to say, hard to find )
There’s a bug in UE 4.14(maybe 4.13 as well, can’t remember) That the tick function execxutes in the blueprint for some reason. So you will have to protect pointers within any functions called in the tick function.
I had the same issue with crashing of the editor upon opening the TankPlayerControlerBP. I had been scratching my head as to why it was crashing, but didn’t think of attaching the debugger, I though the error was in the blueprint or the linking between them.
I opted to install the debug symbols for the engine (In Epic Launcher -> Library -> Arrow next to Launch -> Options). Upon doing that, the crash report gave me direct line number for the offending code.
Wow, I didn’t even realize that was an option… 10Gb of space on the hard drive, but worth it, I’d say. Downloading it now.
I was having an issue where my editor kept crashing when I went to play it, despite a successful compile. I rebooted my PC and went through the code changes I’d made to try and figure it out. I eventually got to the root of the problem by attaching the debugger to UE4.
It turns out the solution was simple (if difficult to spot for a newbie). It turns out I was using GetOwner()-> instead of GetPawn()-> on the following piece of code:
auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
which was throwing back a nullptr causing it to crash.
It’s amazing how something as small as this can cause such a big headache and take so much time if you don’t know what you’re looking for.
Thank you guys for posting your solutions about the TankPlayerController_BP crash. I spent over two hours trying to figure this one out because I wanted to test my Unreal problem solving skills, but I couldn’t quite get there on my own - even with the VS debugger (although I didn’t have the Unreal debug symbols installed - definitely going to do that tonight!)
The Tank has stopped aiming and firing projectile even after i double checked all the changes that you made. But the editor does not crash now which is nice