Aim solution found problem

I slightly changed the code from “if(bHaveAimSolution)” to “if(bHaveAimSolution&&(HitLocation!=FVector(0)))”
in TankAimingComponent.cpp
20180123_111245

Check out this commit

I thought when my crosshair is pointing the sky, “No aim solve found” would be always logged.
But look below.

Please tell me why did that happen?

It is a bug in ue4. Ben talks about it in 142. lecture. It happens to me as well. It looks like calling if and else at the same time. In your case it is called total of 3 times at once but since the first call is negative, it will be unreliably working like it did for me.

I just realized that the reason it calls it twice is because of the ticks. Because we had AimTowards() in TankPlayerController.cpp which calls AimAt() tick and we also call AimAt() tick in TankAIController.cpp. In your case it must be more than it. I don’t think it is a bug anymore. I think we did something wrong with the linetrace. One of the tick calls must be returning a valid value for SuggestProj… and one of them must not. It really had side effects. :slight_smile:

How can I fix the code to avoid the error?

The 2 solution found after the No solution is the solution of AI tanks aiming at you
I don’t think this is a problem

Privacy & Terms