Protection Issues

Hi,

I’m wondering why the protection we do in this lesson does not actually protect Unreal from crashing. The protection code we added was:

	if (!LeftTrackToSet || !RightTrackToSet)
	{
		return;
	}

If we remove Left Track or Right Track references from the Initialize method in the Tank_BP Event Blueprint, then Unreal crashes on playtime. Wasn’t the point of this code to prevent crashing if one of the tracks references was missing???

Great news!

I thought about this a bit more now after a little break and found out the reason we are still crashing is because we did not protect the IntendMoveForward method as well… and it seems that InputAxis is called every frame…

I’ll probably come to realize that we get to this in a future lecture, but just in case we don’t or if someone else runs into a similar issue I’ll post the solution below.

Under:

void UTankMovementComponent::IntendMoveForward(float Throw)
{

Add:

	if (!LeftTrack || !RightTrack)
	{
		return;
	}

Thanks!

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

Privacy & Terms