Nullptr on my barrel?

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

I have set it in initialise():
(Ignore the red - it all goes red temporarily after using the debugger tool)

Thus… I deduce that my problem is in unreal rather than my c++, here I think?:

I can’t see anything wrong with it though. Have I missed something? Should it not be here? Should it be starting on a different event?

FYI, my latest git here:

(Named: 31 - barrel still nullptr - no idea why)

:confounded:

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!

any idea why attaching a debugger to unreal gets stuck on loading symbols for me? After like 5 minutes i give up and hit cancle

Hi @Steve1222

What do you mean by loading symbols?

When I try to attach a debugger; I believe it is attaching but not properly or entirely, because it always gets stuck at this screen/loading box:

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.

Hmm. Mysterious one. Try downloading Ben’s project and see if you get the same crash?

maybe I will at some point. Would be nice to know why the debugger isnt working though.

I think it’s a bug I have a same problem another part of code and then after several times trying problem was solved I don’t why and how

Privacy & Terms