How TankAimingComponent knows about float Launchspeed?
We didnt specified this property in TankAimingComponent…
can someone explain this how this works?
It’s declared in the header file.
Yeah but its declared in Tank header file not in TankAimingComponent
Sorry I forgot I was looking at his current version, LaunchSpeed is being passed in via the parameter.
Thanks for replies…
What you mean its passed in via parameter? Can you explain it more clearly?
void UTankAimingComponent::AimAt(FVector HitLocation, >>float LaunchSpeed<<)
{
//code
}
Those are called parameters, one of which is called LaunchSpeed, which is a float. Meaning when this function is called it expects a FVector and then a float to be passed in.
So basically from what i undersood… TankAimingComponent is a child of Tank? Am i right
No. AimAt is a function of TankAimingComponent, it has two paramaters, an FVector and a float. If you don’t understand that I suggest you go back and watch the lectures on functions back in section 2. Currently trying to find the specfic lecture that goes over parameters.
Section 2, Lecture 12 @ 2:42
But is it because TankAimingComponent.h
is #included into Tank.h
, that we are able to choose this variable as a parameter in a function in TankAimingComponent.h?
No. LaunchSpeed that is used in Tank::AimAt
is the one from the Tank’s class in the Tank.h
UPROPERTY(EditAnywhere, Category = Firing)
float LaunchSpeed = 100000; // TODO find sensible default