Boolean always returning 1

For some weird reason my boolean value for the hitlocation always returned a 1.

I was wondering why I was getting a 1 the whole time, I would like to know how to fix this and I also ask if this has anything to do with my aiming not being smooth, it doesn’t always find where i’m aiming but I still get a return of 1?

this is my github: https://github.com/TimKardaras/RagingWar

Look at your functions, it can only ever return true.

bool ATankPlayerController::GetSightRayHitLocation(FVector &HitLocation) const {
    //code
    if (GetLookDirection(ScreenLocation, LookDirection)) {
        GetLookVectorHitLocation(LookDirection, HitLocation);
    }
	return true;
}

It doessn’t matter what GetLookVectorHitLocation returns because it’s just going to fall to that outside return true statement. If you add a return within that if statement it should get what you expect.

if (GetLookDirection(ScreenLocation, LookDirection)) {
        return GetLookVectorHitLocation(LookDirection, HitLocation);
    }

oh I didn’t push it one sec, have another look, i still have the same error but my github is updated

Seems to be working fine, you just have an extremely high LineTrace length.

What does this mean? are there any consequences because of this?

You’re line tracing the entire distance of the map… and beyond

Blue = trace hit something. white = didn’t. So the code is working fine.

Note: the debug trace lines go even further behind this.

there must be something wrong with it however, because whenever I attempt to aim at the hills or higher my barrel does not follow, I have a limited distance in which I can aim up or down, aiming 360 is fine

Isn’t that expected behavoir? Since it can’t find an aim solution so nothing happens?

But I wouldn’t understand why I can’t aim at the hills next to me without the aiming not following, give it a shot and when you spawn look around to the left at the hills and try look up them, your aiming will come to a hault. I’m not sure why mine does it because I’d assume it is able to find an aim solution to the hills next to me but I may be wrong

That wouldn’t be do to the ATankPlayerController not finding a hitlocation, that would be

bool bHaveAimSolution = UGameplayStatics::SuggestProjectileVelocity

In the AimingComponent not being able to find a valid solution.

I’ll continue to try and fix it up

What I’m saying is, try increasing your Launch Speed in your tank blueprint on the aimingcomponent

1 Like

This actually fixes it, I didn’t expect it to because I have done the same thing before only I set the launch speed way too high so it wouldn’t actually look up and down at all.

Privacy & Terms