When I was coding, got this failure
Severity Code Description Project File Line Suppression State
Error (active) E0304 no instance of overloaded function “TArray<InElementType, InAllocator>::Add [with InElementType=ASnakeElementBase, InAllocator=FDefaultAllocator]” matches the argument list Snake 29
// Fill out your copyright notice in the Description page of Project Settings.
#include "SnakeBase.h"
#include "SnakeElementBase.h"
// Sets default values
ASnakeBase::ASnakeBase()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
ElementSize = 100.f;
}
// Called when the game starts or when spawned
void ASnakeBase::BeginPlay()
{
Super::BeginPlay();
AddSnakeElement(4);
}
void ASnakeBase::AddSnakeElement(int ElementsNum)
{
for (int i = 0; i < ElementsNum; ++i)
{
FVector NewLocation(SnakeElements.Num() * ElementSize, 0, 0);
FTransform NewTranform(NewLocation);
auto NewSnakeElem = GetWorld()->SpawnActor<ASnakeElementBase>(SnakeElementClass, NewTranform);
SnakeElements.Add(NewSnakeElem);
}
}
If you can help me and explain what was the failure moment, it will be greate)
Tried any different ways to solve it, but not successed
Volazar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.