Skip to content

Commit

Permalink
BE11 Moving Objects With C++
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Tristem committed Feb 22, 2016
1 parent cb3b711 commit adfe11e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
Binary file modified BuildingEscape/.vs/BuildingEscape/v14/.suo
Binary file not shown.
8 changes: 4 additions & 4 deletions BuildingEscape/BuildingEscape.sln
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{01375FDA-FE11-4ACD-952B-65DD69A30679}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{38320630-9C6E-4057-A3CE-9610CBEE7B07}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Games", "Games", "{E620744E-C730-4438-AC96-6A484540ACA7}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Games", "Games", "{B003838A-BEAD-4610-BBDF-4DA79257AC63}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UE4", "Intermediate\ProjectFiles\UE4.vcxproj", "{5591C069-C731-4027-B356-7B9A5769CECE}"
EndProject
Expand Down Expand Up @@ -70,7 +70,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5591C069-C731-4027-B356-7B9A5769CECE} = {01375FDA-FE11-4ACD-952B-65DD69A30679}
{B4691DEB-2073-4692-A4F6-E496EA81A368} = {E620744E-C730-4438-AC96-6A484540ACA7}
{5591C069-C731-4027-B356-7B9A5769CECE} = {38320630-9C6E-4057-A3CE-9610CBEE7B07}
{B4691DEB-2073-4692-A4F6-E496EA81A368} = {B003838A-BEAD-4610-BBDF-4DA79257AC63}
EndGlobalSection
EndGlobal
Binary file modified BuildingEscape/Content/NewMap.umap
Binary file not shown.
42 changes: 42 additions & 0 deletions BuildingEscape/Source/BuildingEscape/OpenDoor.cpp
@@ -0,0 +1,42 @@
// Copyright Ben Tristem 2016.

#include "BuildingEscape.h"
#include "OpenDoor.h"


// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
// 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.
bWantsBeginPlay = true;
PrimaryComponentTick.bCanEverTick = true;

// ...
}


// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();

// Find the owning Actor
AActor* Owner = GetOwner();

// Create a rotator
FRotator NewRotation = FRotator(0.f, -60.f, 0.f);

// Set the door rotation
Owner->SetActorRotation(NewRotation);
}


// Called every frame
void UOpenDoor::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );

// ...
}

26 changes: 26 additions & 0 deletions BuildingEscape/Source/BuildingEscape/OpenDoor.h
@@ -0,0 +1,26 @@
// Copyright Ben Tristem 2016.

#pragma once

#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UOpenDoor : public UActorComponent
{
GENERATED_BODY()

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

// Called when the game starts
virtual void BeginPlay() override;

// Called every frame
virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;



};

4 comments on commit adfe11e

@farmshot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include "EscapeBuilding.h"
#include "OpenDoor.h"
Do I need to include something else?
opendoor.cpp is same as above, as well as .h

I am using 4.18 UE

Super::BeginPlay();
//finds the owner actor
AActor* Owner = GetOwner();
//creates the rotator
FRotator NewRotation = FRotator(0.0f, -60.0f, 0.0f);
// set door rotation
Owner->SetActorRotation(NewRotation);

get squiggly line under "Owner"->SetActorRotation(NewRotation);
with: "pointer to incomplete class type is not allowed"

@patmilano
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farmshot Make sure that you have included the proper files (IWYU) if your version is above UE 4.16. You will need to include the AActor header file found here in order for Unreal to know what you are looking for.

@Levener
Copy link

@Levener Levener commented on adfe11e Jan 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farmshot Make sure that you have included the proper files (IWYU) if your version is above UE 4.16. You will need to include the AActor header file found here in order for Unreal to know what you are looking for.

Hi @patmilano,
Your link to the header file is down. I'm having the same problem as farmshot, above.

@t999uk
Copy link

@t999uk t999uk commented on adfe11e Feb 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patmilano @farmshot just add the following line to the top of your code
#include "GameFramework/Actor.h

Please sign in to comment.