I have an error in my code that i dont know how to fix

soooo i have this error and i don’t know how to fix here’s the message it shows me when i try to compile

and here’s the code when i click the link


can someone help??

Can you post your header file? TankAimingComponent.h
To me it looks like you may have misspelled SetBarrelReference somewhere?

1 Like

heres the .h file

(i fixed allot of problems but i still have this)

i dint can you help heres when i try to compile

Could you show your updated code?

1 Like

i mean i errased some things but here you go

heres the bottom part

Could you post the full header and cpp please?

1 Like

ok here you go i did something to the cpp file to see if it worked but it dint but here you go

#include "TankAimingComponent.h"
#include "TankBarrel.h"
#include "Kismet/GameplayStatics.h"
#include "Components/StaticMeshComponent.h"


// Sets default values for this component's properties
UTankAimingComponent::UTankAimingComponent()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}
void UTankAimingComponent::SetBarrelReference(UTankBarrel* BarrelToSet)
{
	Barrel = BarrelToSet;
}
// Called when the game starts

void UTankAimingComponent::AimAt(FVector HitLocation, float LaunchSpeed)
{
	if (!Barrel) { return; }

	FVector OutLaunchVelocity;
	FVector StartLocation = Barrel->GetSocketLocation(FName("Projectile"));

	bool BHaveAimSolution = UGameplayStatics::SuggestProjectileVelocity
	(
		this,

		OutLaunchVelocity,
		StartLocation,
		
		HitLocation,
		LaunchSpeed,

		ESuggestProjVelocityTraceOption::DoNotTrace
	);

		if(BHaveAimSolution)
	{
		auto AimDirection = OutLaunchVelocity.GetSafeNormal();
		MoveBarrelTowards(AimDirection);
	};
	// If no solution found do nothing
}

void UTankAimingComponent::MoveBarrelTowards(FVector AimDirection)
{
	// Work-out difference between current barrel roation, and AimDirection
	auto BarrelRotator = Barrel->GetForwardVector().Rotation();

	auto AimAsRotator = AimDirection.Rotation();

	auto DeltaRotator = AimAsRotator - BarrelRotator;

	Barrel->Elevate(5); // TODO remove magic number
}

im sorry and heres the .h file

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include <wrl\def.h>
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "TankAimingComponent.generated.h"

// Forward Declaration
class UTankBarrel;


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BATTLETANK_4_API UTankAimingComponent : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UTankAimingComponent();

	void SetBarrelReference(UTankBarrel* BarrelToSet);

	void AimAt(FVector HitLocation, float LaunchSpeed);

private:
	UTankBarrel* Barrel = nullptr;

	void MoveBarrelTowards(FVector AimDirection);
};

i dont know how to put all of it in like the gray area but there you go if you want screen shoots tell me…

Use this button

image

1 Like

And you’re getting the exact same error in this post?

Because that doesn’t like that error should happen with the code you posted.

1 Like

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

Privacy & Terms