Hi Ben
I watched this Lecture hundreds of times but i really dont understand why you creating this
auto AimingDirection = OutLaunchVelocity.GetSafeNormal();
Can you explain it a little more?
Thanks
Hi Ben
I watched this Lecture hundreds of times but i really dont understand why you creating this
auto AimingDirection = OutLaunchVelocity.GetSafeNormal();
Can you explain it a little more?
Thanks
Hi Wilku,
I’m not Ben but I think I can help you with this.
I hope you understand my English. (Any correction is well receive ^^)
As you might remember, UGameplayStatics::SuggestProjectileVelocity
has an out parameter (OutLaunchVelocity) and returns a boolean at the same time. What this means is that if this method returns true then OutLaunchVelocity will be written with the LaunchVelocity, but that launch velocity is nothing more than a vector which happens to have the same direction we are pointing at (Where we want our turret/barrel to rotate to).
The reason auto AimingDirection = OutLaunchVelocity.GetSafeNormal()
is added is because the
UTankAimingComponent::MoveBarrelTowards
method needs to know where to rotate the barrel. Now, since is only using the rotation of that AimingDirection he could’ve said
auto AimRotation = LaunchVelocity.Rotation(); UTankAimingComponent::MoveBarrelTowards(AimRotation);
And change the signature of the MoveBarrelTowards to receive a FRotator instead of a FVector and remove the AimDirection.Rotation()
from that same method. But I think that’s legacy code that hasn’t change (maybe because he forgot and it has been working as it is now).
To summarize, you are right, as it is right now, MoveBarrelTowards doesn’t need to receive “AimDirection”, instead should receive AimRotation (LaunchVelocity.Rotation()), but that method hasn’t change in a long time so he maybe forgot to make that change since right now, as it is, is doing the job.
Maybe I confuse you more than you were already. I’m learning as well as you are and I usually have a hard time explaining thing (in English is harder for me XD), so anyone is welcome to correct me if anything I said is wrong. I like criticism.
Hope this helped you!