I'm currently creating a little video sequence for a game in Unreal and have written a CameraDirector
-class for this purpose. At the name says, it controls the players view around different camera objects played in the world.
Now I want to make my program more flexible, so I decided to put all the Camera's into an std::vector
-container and use a for file to iterate through it. Now here is the problem:
#include <vector>
using namespace std;
When I put this in the header to import the std::vector
, a LOT of the standard stuff created automatically by Unreal-Engine was underlined red and was no longer recognized by VS. I didn't touch a lot of this stuff, but nevertheless it wont compile anymore.
When I remove these two lines everything is fine again but I can't use std::vector.
Why does my import interferes with the program so much?
I'm using VS-2015 and Unreal Engine 4.17.1
Edit:
Due to being marked as a duplicate, it also breaks as well when I ONLY write #include <vector>
. I don't see the connection to the linked question
Code in the header:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CameraDirector.generated.h"
#include <vector>
UCLASS()
class HOWTO_AUTOCAMERA_API ACameraDirector : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACameraDirector();
APlayerController* OurPlayerController = UGameplayStatics::GetPlayerController(this, 0);
const float TimeBetweenCameraChanges = 4.0f;
const float SmoothBlendTime = 0.75f;
const float SlowBlendTime = 1.5f;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
bool isAllCamerasSelected();
void createNewCameraMove(AActor* Camera, float movingTime);
UPROPERTY(EditAnywhere)
AActor* CameraOne;
UPROPERTY(EditAnywhere)
AActor* CameraTwo;
UPROPERTY(EditAnywhere)
AActor* CameraThree;
float TimeToNextCameraChange;
};
.cpp :
// Fill out your copyright notice in the Description page of Project Settings.
#include "CameraDirector.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
ACameraDirector::ACameraDirector()
{
// 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;
}
// Called when the game starts or when spawned
void ACameraDirector::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ACameraDirector::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
TimeToNextCameraChange -= DeltaTime;
if (TimeToNextCameraChange <= 0.0f)
{
TimeToNextCameraChange += TimeBetweenCameraChanges;
if (OurPlayerController && isAllCamerasSelected())
{
if ((OurPlayerController->GetViewTarget() != CameraTwo) && (OurPlayerController->GetViewTarget() != CameraThree))
{
// Blend smoothly to camera two.
OurPlayerController->SetViewTargetWithBlend(CameraTwo, SmoothBlendTime);
}
else if ((OurPlayerController->GetViewTarget() != CameraOne) && (OurPlayerController->GetViewTarget() != CameraThree))
{
// Blend slowly to camera three.
OurPlayerController->SetViewTargetWithBlend(CameraThree, SlowBlendTime);
}
else if ((OurPlayerController->GetViewTarget() != CameraTwo) && (OurPlayerController->GetViewTarget() != CameraOne))
{
// Cut instantly to camera one.
OurPlayerController->SetViewTarget(CameraOne);
}
}
}
}
bool ACameraDirector::isAllCamerasSelected()
{
return ((CameraOne != nullptr) && (CameraTwo != nullptr) && (CameraThree != nullptr));
}
void ACameraDirector::createNewCameraMove(AActor * Camera, float movingTime)
{
OurPlayerController->SetViewTargetWithBlend(Camera, movingTime);
}
Severity Code Description Project File Line Error (active) name followed by '::' must be a class or namespace name HowTo_AutoCamera d:\Leon\Unreal\HowTo_AutoCamera\Source\HowTo_AutoCamera\CameraDirector.cpp 10