After refactoring I’ve got an error driving me bonkers! It’s the usual crashing out on Play. I’ve got ensures on all my pointer protected code (am I saying that right? on all the if (!ensure()){return;} code). But am I right in think that’s useless if it’s a hard crash?
So I have attached the VS debugger to UE4 like we were previously shown, and it tells me I’ve got a nullptr on my protected barrel. I.e… the barrel is not set
Just in case anyone is looking at this I had better let you know it is fixed now.
Figured out that the problem isn’t exactly on the line the debugger said it was. It derived from calling the AimAt method in player and ai scripts.
I deviated from Ben’s code here and they weren’t correctly protected. So by protecting that code properly, it was able to bail out of the Tick (in Ai) and AimTowardsCrosshair (in Player) scripts before calling AimAt and it no longer crashed.
In order to actually get it working, I had to change how I was referencing AimAt.
I was using (what I thought was safe) UTankAimingComponent->AimAt
I actually don’t understand why that doesn’t work as I am sure that was how we originally did it when we called it from Tank??? (I had linked the pointer, etc in the header file)
Any feedback on why that might not be possible to do here would be great!
My project always crashes at random, if you were to play it you would most likely find at some point it would crash. Even if you played the one from before if its still sitting on your hard drive. Well, unless this problem is on my PC’s end, but I doubt it since the problem only occured when ben first showed us how to spawn the projectile class we made into the world, of upon which it would crash seemingly on a random projectile spawn instance.
I had a similar problem with this last night and half solved it here:
The way I solved this problem might give some insight as to the cause of the other/related problem. The ensures werent even working BTW on the projectile class reference. The debugger sounds like it could be useful but thus i cannot manage to attach one.
So there is this problem and the problem that I can’t use the debugger. There is a link to my project in the thread I linked to but I will also link it here:
^The above project will crash during play when you fire your weapon; to solve this set a projectile class in the tank pawn’s aiming component settings, as mentioned in the half-solution.