The character doesn't seem to be able to do damage

float AShooterCharacter::TakeDamage(float DamageAmount, struct FDamageEvent const &DamageEvent, class AController *EventInstigator, AActor *DamageCauser)
{
	float DamageToApply = Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);


	DamageToApply = FMath::Min(Health, DamageToApply);

	Health -= DamageToApply;
	
	UE_LOG(LogTemp, Warning, TEXT("Health: %f"), Health);

	return DamageToApply;
}

image
I hit the AI with a gun as shown in the picture. But the log doesn’t show up, and if I shoot and get hit somewhere as shown in the picture below, the effect appears, but it doesn’t only show up to the AI.
image

If you go near the AI and shoot, the AI’s stamina is only reduced. There are logs, too.
But sometimes I think I’m aiming at AI and shooting, but it doesn’t really reduce my stamina. Is it because I’m not doing well in testing…
It feels like you have to shoot a certain area to reduce your stamina.

So you’re getting the log only sometimes? Are you sure the line trace is where you think it is?

That’s right! I don’t know if it’s where I think it is.
I even implemented AI’s movement. But before AI moves, you have to shoot from the side of the AI, not in front of it, and the logarithm is good. Should I say that it feels like it’s only in a certain area?

AI is on the move now. Sometimes I get logs well. But sometimes I don’t.

Have you added a debug line trace/point to see where the actual trace/end point is?

Are you talking about DrawDebugLine() if it’s a debug line?

If you’re talking about this, I didn’t add it.

I’m suggesting you add one so you can see if the line trace you’re doing is correct.

1 Like

Privacy & Terms