Engine crashing everytime!

After I put this code, my engine is crashing,

Did you find out the error yet?

Does the editor crash window give a line number? If it is line 16 then it means that TankRoot is null. The cast in line 15 failed if that is the case… which seems a bit weird.

yes my line 16 is giving error . when i commented it and played the game was working, please tell me whats wrong with the line 16?

Your tank’s root component isn’t the tank body.

I don’t get it, I am a beginner please explain me in detail what to do .

Look at your component list for the tank.

tv

And in code you asked to get the root component and cast it to UPrimitiveComponent. Your root component is “DefaultSceneRootComponent” which is a USceneComponent which is not a UPrimitiveComponent. Which means your cast will return nullptr and then dereferncing that == bad times.

Click and drag TankBody onto DefaultSceneRoot to make it the new root component. You can then delete that scene component.

1 Like

Thank You!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms