I Dont know what or where the problemđ˘
when I give it 40
TankBarrel.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "BattleTank/Public/TankBarrel.h"
void UTankBarrel::Elevate(float RelativeSpeed)
{
//MMove the barrel thr right amount this frame
//Given max elevation speed , and the frame time
RelativeSpeed= FMath::Clamp<float>(RelativeSpeed,-1,+1);
auto ElevationChange = RelativeSpeed * MaxDegreesPerSecond * GetWorld()->DeltaTimeSeconds;
auto RawNewElevation = GetRelativeRotation().Pitch + ElevationChange;
auto Eelvation =FMath::Clamp<float>(RawNewElevation ,MinElevateDegrees ,MaxElevateDegrees);
SetRelativeRotation(FRotator(Eelvation,0,0));
// UE_LOG(LogTemp,Warning,TEXT("Barre; -Elevate() called at %f"), RelativeSpeed) //debug
}
TankAimingComponent.cpp
void UTankAimingComponent::MoveBarrelTowards(FVector AimDirection)
{
//work-out difference between current barrel roation AimDirection
auto BarrelRotation = Barrel ->GetForwardVector().Rotation();
auto AimAsRotator = AimDirection.Rotation();
auto DeltaRotator = AimAsRotator - BarrelRotation;
//MMove the barrel thr right amount this frame
//Given max elevation speed , and the frame time
Barrel->Elevate(DeltaRotator.Pitch); //To do magic number
}