My tank Does not reach the highest degree

I Dont know what or where the problem😢
when I give it 40

!

Annotation 2020-06-03 153602

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
}

I assume it just doesn’t need to aim higher?

Your words are correct, but I was sad that my “code” didn’t work like in the lesson
On the other hand when I removed the “static mesh” it worked correctly

So if you raise the terrain to be able to aim higher it works as expected?

I can say yes

Does the barrel have collision?

Yes and I have tried without it

Can’t remember if auto weld affects that setting, could you try with removing it from the mesh itself?

I have downloaded “barrel” again and it looks good

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms