How Going through the Steps of Asking a Good Question can Help you Fix your Bug

TankAimingBug

I fixed this incorrect aiming bug by using the github repo, but going through the “How to Ask a Good Question” steps got me there, so here they are:

Expected Behavior

The projectile’s velocity is in the same direction of the barrel.

Observed Behavior

When I’m facing forward / world X axis it fires fine. The more I aim left or right the more the projectile spawns to the left or right of the barrel respectively.

Steps to Reproduce

Occurs in this latest commit.

Already Tried

  • Drawing persistent debug lines in Fire too see how they don’t match up with the projecile’s direction.
  • Playing with Launch Speed

Useful Info / Code

  • I finally noticed that this line:
    ProjectileMovementComponent->SetVelocityInLocalSpace(GetActorForwardVector() * Speed);
  • Should be
    ProjectileMovementComponent->SetVelocityInLocalSpace(FVector::ForwardVector * Speed);

Thanks for reading, and I hope that those steps help you as well.

Privacy & Terms