Red lines whyyy ?

Hi i need help with red lines in my visual 2022 or vscode still have errors i try everything but not work still have error (i try generating files,reinstall vs2022,extensions) what with this thank you very much :confused:


how did you end up creating this MyActor class? (was this done through the Editor “Tools”->“new C++ class…”; or did you just add the files manually in file explorer/VSCode) if you didn’t go through the editor to create it, it might end up working out, but in most cases it will not work completely with the reflection system in blueprints, and if you fully setup the integration of Unreal Header Tool and Unreal Build Tool could play havoc with those as well.

for the situation at hand the biggest issue is the compiler not recognizing “GameFramework/Actor.h” (sometimes an IDE will see an include as invalid, then just throw up its hands, and invalidate the entire file meaning it technically doesn’t exist) first try changing #include "GameFramework/Actor.h" to be #include "CoreMinimal.h" and see if that fixes the *.h file in question which should “just fix” the errors with the *.cpp

if that doesn’t end up working then I might have to ask:
*Are you compiling the engine from source, or using the Epic Games Launcher installed binaries?

*Are you sure that you followed all the steps to setup VSCode Setting Up Visual Studio Code for Unreal Engine | Unreal Engine 5.3 Documentation, sometimes missing a single step can prevent things from working properly.

i try everithing and now reisntall pc and errors still have i install all but not wokr and i dont know if this right code ? thnak you


// MyProjectile.cpp
#include "MyProjectile.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "DrawDebugHelpers.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/World.h" // Include this header

// Sets default values
AMyProjectile::AMyProjectile()
{
    // Set this actor to call Tick() every frame
    PrimaryActorTick.bCanEverTick = true;

    // Create projectile movement component
    ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovement"));
    ProjectileMovement->bAutoActivate = false;

    // Initialize other variables here
    ExplosionEffect = nullptr;
    NumFragments = 0;
    ConeRadius = 45.0f;
    ExplosionRadius = 100.0f;
}

// Called when the game starts or when spawned
void AMyProjectile::BeginPlay()
{
    Super::BeginPlay();

    // Add any specific logic that should occur when the projectile is spawned
}

// Called every frame
void AMyProjectile::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
}

void AMyProjectile::OnHit(AActor* HitActor, const FVector& HitLocation)
{
    // Calculate the distance between the projectile and the hit location
    float DistanceToHitLocation = FVector::Dist(GetActorLocation(), HitLocation);

    // Check if the distance is less than 5 meters
    if (DistanceToHitLocation <= 500.0f) // Assuming Unreal units
    {
        // Implement your explosion logic here
        // For example, you can spawn a particle effect, apply damage, etc.

        if (ExplosionEffect)
        {
            UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), ExplosionEffect, HitLocation, FRotator::ZeroRotator, true);
        }

        // Create fragments in a cone
        for (int32 i = 0; i < NumFragments; ++i)
        {
            FVector FragmentDirection = FMath::VRandCone(GetActorForwardVector(), FMath::DegreesToRadians(ConeRadius));
            FVector FragmentLocation = HitLocation + FragmentDirection * ExplosionRadius;

            // Spawn fragment actor or particle effect
            // Example: UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), FragmentEffect, FragmentLocation, FRotator::ZeroRotator, true);
        }

        // Destroy the projectile
        Destroy();
    }
    else
    {
        // Handle the case when the projectile doesn't explode (e.g., pass through without exploding)
    }
}

SOLVED api need big words name projetc .h :smiley: