├── README.md ├── Basic_Procedural_Spawned_Tree_HeaderFile ├── Basic_Procedural_Spawned_Tree_CPPFile ├── Basic_Spawner_Spawned_object_Header ├── Basic_Spawner_Spawned_Object_CPP_File ├── Basic_Spawner_Controller_Code_Header ├── Light_Switch_HeaderFile ├── Timer_Example_Spawner_Header_File ├── Basic_Health_Pack_Header ├── Basic_Procedural_Forest_Controller_HeaderFile ├── Light_Switch_CPPFile ├── Timer_Example_Spawner_CPP_File ├── Basic_Spawner_Controller_Code_CPP_File ├── Basic_Health_Pack_CPP └── Basic_Procedural_Forest_Controller_CPPFile /README.md: -------------------------------------------------------------------------------- 1 | # Unreal-Engine-Code-Help 2 | Just some code to help people with unreal engine 4 3 | The Following code in here is ment to help people(beginners) with programming in 4 | unreal engine 4 5 | -------------------------------------------------------------------------------- /Basic_Procedural_Spawned_Tree_HeaderFile: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------------------------------------- 2 | // This is the basic code for the class that is being spawned. Nothing is in here, because its a tree and doesnt need code. - 3 | // Please Give Credit for any code used. Thanks, - 4 | // Nicholas Mallonee - 5 | // Unreal Engine 4 - 6 | // Version 4.7.6 - 7 | // Date: 4.8.15 -- Day, Month, Year - 8 | //---------------------------------------------------------------------------------------------------------------------------------------------- 9 | 10 | 11 | //---------------------------------------------------------------------------------------------------------------------------------------------- 12 | // Prama's and Defines - 13 | //---------------------------------------------------------------------------------------------------------------------------------------------- 14 | #pragma once 15 | 16 | //---------------------------------------------------------------------------------------------------------------------------------------------- 17 | // Libaries and Includes - 18 | //---------------------------------------------------------------------------------------------------------------------------------------------- 19 | #include "GameFramework/Actor.h" // Include the actor class we are inheirting from 20 | #include "Proc_Tree.generated.h" // Include this classes header file 21 | 22 | UCLASS() 23 | class HARDCORE_API AProc_Tree : public AActor 24 | { 25 | GENERATED_BODY() 26 | 27 | public: 28 | // Sets default values for this actor's properties 29 | AProc_Tree(); 30 | 31 | // Called when the game starts or when spawned 32 | virtual void BeginPlay() override; 33 | 34 | // Called every frame 35 | virtual void Tick( float DeltaSeconds ) override; 36 | }; 37 | -------------------------------------------------------------------------------- /Basic_Procedural_Spawned_Tree_CPPFile: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------------------------------------- 2 | // This is the basic code for the class that is being spawned. Nothing is in here, because its a tree and doesnt need code. - 3 | // Please Give Credit for any code used. Thanks, - 4 | // Nicholas Mallonee - 5 | // Unreal Engine 4 - 6 | // Version 4.7.6 - 7 | // Date: 4.8.15 -- Day, Month, Year - 8 | //---------------------------------------------------------------------------------------------------------------------------------------------- 9 | 10 | 11 | //---------------------------------------------------------------------------------------------------------------------------------------------- 12 | //Libraries and includes - 13 | //---------------------------------------------------------------------------------------------------------------------------------------------- 14 | #include "HardCore.h" // The Game that this is in 15 | #include "Proc_Tree.h" // This Classes Header file 16 | 17 | //---------------------------------------------------------------------------------------------------------------------------------------------- 18 | // Constructors and Engine Events - 19 | //---------------------------------------------------------------------------------------------------------------------------------------------- 20 | AProc_Tree::AProc_Tree() // -- Default Constructor -- // 21 | { 22 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 23 | PrimaryActorTick.bCanEverTick = true; 24 | 25 | } 26 | 27 | void AProc_Tree::BeginPlay() // -- Begin Play Engine Event -- // 28 | { 29 | Super::BeginPlay(); 30 | 31 | } 32 | 33 | void AProc_Tree::Tick( float DeltaTime ) // -- Frame Tick Engine Event -- // 34 | { 35 | Super::Tick( DeltaTime ); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Basic_Spawner_Spawned_object_Header: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------- 2 | // This class is spawned by the basic spawner class. This is the default actor code from unreal engine, the only - 3 | // difference is that, in the spawner code, we call this header file to have access to all the methods so that we- 4 | // can spawn the object. - 5 | // Nicholas Mallonee - 6 | // Unreal Engine 4.7.6 - 7 | //---------------------------------------------------------------------------------------------------------------- 8 | 9 | //---------------------------------------------------------------------------------------------------------------- 10 | // Pragma's and Defines - 11 | //---------------------------------------------------------------------------------------------------------------- 12 | #pragma once 13 | 14 | //---------------------------------------------------------------------------------------------------------------- 15 | // Libraries and Includes - 16 | //---------------------------------------------------------------------------------------------------------------- 17 | #include "GameFramework/Actor.h" // The class we are inheirting from 18 | #include "PowerUP_Parent.generated.h" // This class' header file 19 | 20 | UCLASS() 21 | class CATCH_ME_IF_YOU_CAN_API APowerUP_Parent : public AActor 22 | { 23 | GENERATED_BODY() 24 | 25 | public: 26 | // Sets default values for this actor's properties 27 | APowerUP_Parent(); // Default Constructor 28 | 29 | // Called when the game starts or when spawned 30 | virtual void BeginPlay() override; 31 | 32 | // Called every frame 33 | virtual void Tick( float DeltaSeconds ) override; 34 | 35 | 36 | 37 | }; 38 | -------------------------------------------------------------------------------- /Basic_Spawner_Spawned_Object_CPP_File: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------- 2 | // This class is spawned by the basic spawner class. This is the default actor code from unreal engine, the only - 3 | // difference is that, in the spawner code, we call this header file to have access to all the methods so that we- 4 | // can spawn the object. - 5 | // Nicholas Mallonee - 6 | // Unreal Engine 4.7.6 - 7 | //---------------------------------------------------------------------------------------------------------------- 8 | 9 | //---------------------------------------------------------------------------------------------------------------- 10 | // Libraries and Includes - 11 | //---------------------------------------------------------------------------------------------------------------- 12 | #include "Catch_Me_If_You_Can.h" // The game / package that this class is used in 13 | #include "PowerUP_Parent.h" // This classes header file 14 | 15 | 16 | 17 | APowerUP_Parent::APowerUP_Parent() // -- The default constructor -- // 18 | { 19 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 20 | PrimaryActorTick.bCanEverTick = true; 21 | 22 | } 23 | 24 | void APowerUP_Parent::BeginPlay() // -- Begin Play Event -- // 25 | { 26 | Super::BeginPlay(); 27 | 28 | // This method is called right when this object is spawned into the world or when the game starts. 29 | // Any methods, variables or anything, will be called as soon as possible! 30 | 31 | } 32 | 33 | void APowerUP_Parent::Tick( float DeltaTime ) // -- Tick Event -- // 34 | { 35 | Super::Tick( DeltaTime ); 36 | 37 | // This method is the frame tick event! 38 | // It is called every single frame! 39 | // The Argument it takes a delta time, or a delta second. 40 | // Which is a peice of time or a piece of a second. 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Basic_Spawner_Controller_Code_Header: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------- 2 | // This class generates the spawn solutions for any power-ups that will affect the player during the game time. - 3 | // This is similar to the falling object controller, however it is more time sensitive. It will need to check - 4 | // the time between spawns to make sure that is universal and never fails. - 5 | // Nicholas Mallonee - 6 | // Unreal Engine 4.7.6 - 7 | //---------------------------------------------------------------------------------------------------------------- 8 | 9 | //---------------------------------------------------------------------------------------------------------------- 10 | // Pragma's and Defines - 11 | //---------------------------------------------------------------------------------------------------------------- 12 | #pragma once 13 | 14 | //---------------------------------------------------------------------------------------------------------------- 15 | // Libraries and Includes - 16 | //---------------------------------------------------------------------------------------------------------------- 17 | #include "GameFramework/Actor.h" // Accesses the basic actor methods 18 | #include "PowerUP_Parent.h" // The Classs we are going to spawn with this controller(need to have a path if not in the same folder) 19 | #include "PowerUp_Controller.generated.h" // This class' header fiile(gen by unreal engine) 20 | 21 | //---------------------------------------------------------------------------------------------------------------- 22 | // Base Class Header Infromation - 23 | //---------------------------------------------------------------------------------------------------------------- 24 | UCLASS() 25 | class CATCH_ME_IF_YOU_CAN_API APowerUp_Controller : public AActor 26 | { 27 | GENERATED_BODY() 28 | 29 | // -- Public Information -- Constructors and Engine Events -- // 30 | public: 31 | APowerUp_Controller(); // Default Constructor 32 | 33 | APowerUp_Controller(const FObjectInitializer& ObjectInitializer); // Argumented Constructor 34 | 35 | virtual void BeginPlay() override; // Begin play, spawn intstruction 36 | 37 | virtual void Tick( float DeltaSeconds ) override; // Frame tick event 38 | 39 | float generateX(float DeltaSeconds); // Generate a new X 40 | 41 | float currentTime; // Keep the current alive time 42 | 43 | float xCord; // Holds the new x coord 44 | 45 | FTransform ourOldSpawnLocation; // Hold all of our old spawn information 46 | 47 | FVector ourLoc; // Hold our spawn location 48 | 49 | FRotator ourRotation; // Hold the rotation of the object 50 | 51 | UPROPERTY(EditDefaultsOnly, Category = "Our Spawning Object") 52 | TSubclassOf ourSpawningObject; // Holds the blue prints of the object we want to spawn 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /Light_Switch_HeaderFile: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------------------------------------------------------- 2 | // This is a simple light switch class that a player can turn on and off - 3 | // Nicholas Mallonee - 4 | // Unreal Engine 4.7.6 - 5 | //--------------------------------------------------------------------------------------------------------------------------------------- 6 | 7 | 8 | //--------------------------------------------------------------------------------------------------------------------------------------- 9 | // Preagmas and Defines - 10 | //--------------------------------------------------------------------------------------------------------------------------------------- 11 | #pragma once 12 | 13 | //--------------------------------------------------------------------------------------------------------------------------------------- 14 | // Libraries and Includes - 15 | //--------------------------------------------------------------------------------------------------------------------------------------- 16 | #include "GameFramework/Actor.h" 17 | #include "FuseBox.generated.h" 18 | 19 | 20 | //--------------------------------------------------------------------------------------------------------------------------------------- 21 | // Event Declare - 22 | //--------------------------------------------------------------------------------------------------------------------------------------- 23 | 24 | //--------------------------------------------------------------------------------------------------------------------------------------- 25 | // Class information - 26 | //--------------------------------------------------------------------------------------------------------------------------------------- 27 | UCLASS() 28 | class HAUNTEDHOUSESIM_API AFuseBox : public AActor 29 | { 30 | GENERATED_BODY() 31 | 32 | // -- Public Information -- Constructor and engine events -- // 33 | public: 34 | AFuseBox(); // Default constuctor 35 | 36 | AFuseBox(const FObjectInitializer& ObjectInitializer); // Argumeneted Constructor 37 | 38 | virtual void BeginPlay() override; // Begin Play Event 39 | 40 | virtual void Tick( float DeltaSeconds ) override; // Frame Tick Event 41 | 42 | virtual void ReceiveActorBeginOverlap(class AActor* Other) override; // Being Overlap method 43 | 44 | virtual void ReceiveActorEndOverlap(class AActor* Other) override; // End overlap method for collision 45 | 46 | // -- Private Information -- Mesh, light comp, and Collision -- // 47 | private: 48 | UPROPERTY(EditDefaultsOnly, Category = "My Mesh") // holds the static for our object 49 | UStaticMeshComponent* ourMesh; 50 | 51 | USphereComponent* collisionComp; 52 | 53 | // hold the light we are going to turn on or off 54 | UPointLightComponent* ourLight; 55 | 56 | // -- Private Information -- Switches State -- // 57 | private: 58 | bool bIsOn; // hold if the light is on or off 59 | 60 | // -- Public Information -- Outside accessors and mutators -- // 61 | public: 62 | void toggleLight(); // allows for a class to toggle the light 63 | }; 64 | -------------------------------------------------------------------------------- /Timer_Example_Spawner_Header_File: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------- 2 | // This is a simple timer example. This asset will simply spawn a number of "Orbs" around the origin of the game - 3 | // world. Once the selected number of assets is completed it will unbind the timer handle and wait to be removed by - 4 | // the end play event. You can freely use this example in your unreal engine projects! Just let me know if you - 5 | // have any questioms. - 6 | // - 7 | // Nicholas Mallonee - 8 | // Unreal Engine 4.7.6 -> 4.10.1 - 9 | //------------------------------------------------------------------------------------------------------------------- 10 | 11 | //------------------------------------------------------------------------------------------------------------------- 12 | // Pragmas and defines - 13 | //------------------------------------------------------------------------------------------------------------------- 14 | #pragma once 15 | 16 | //------------------------------------------------------------------------------------------------------------------- 17 | // Libraries and Includes - 18 | //------------------------------------------------------------------------------------------------------------------- 19 | #include "GameFramework/Actor.h" // Inheirt from the actor class 20 | #include "Resources/StructExamples/Orbs/Orb.h" // This is the path to the object we are going to spawn 21 | #include "OrbSpawner.generated.h" // This classes header file. Generated by the engine 22 | 23 | //------------------------------------------------------------------------------------------------------------------- 24 | // Class Information - 25 | //------------------------------------------------------------------------------------------------------------------- 26 | UCLASS() 27 | class AI_PLAYGROUND_API AOrbSpawner : public AActor 28 | { 29 | GENERATED_BODY() 30 | 31 | // -- Public information -- Constructor and engine events -- // 32 | public: 33 | AOrbSpawner(); // Class Constructor 34 | 35 | virtual void BeginPlay() override; // Begin Play Event 36 | 37 | virtual void Tick( float DeltaSeconds ) override; // Frame Tick Event 38 | 39 | virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; // End Play Event 40 | 41 | // -- Private Information -- Orb Spawning -- // 42 | private: 43 | void handleSpawn(); // Handles the Spawning logic tree 44 | 45 | void cleanUpTimer(); // Cleans up the timer and unbinds it 46 | 47 | void spawnOrb(); // Spawns the orb into the game world 48 | 49 | // -- Private Information -- Timer Handling Variables -- // 50 | private: 51 | UPROPERTY(EditDefaultsOnly, Category = "Run Amount") 52 | int32 spawnerCount; // Holds the number of actors to spawn 53 | 54 | // -- Private Information -- Orb to Spawn -- // 55 | private: 56 | UPROPERTY(EditDefaultsOnly, Category = "Basic Orb") 57 | TSubclassOf ourOrb; // The thing we are going to spawn 58 | 59 | // -- Private Information -- Timer Handle -- // 60 | private: 61 | FTimerHandle spawnTimerHandler; // The timer handle, use this for 4.7.2 on 62 | }; 63 | -------------------------------------------------------------------------------- /Basic_Health_Pack_Header: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------------------------------------------------------- 2 | // This is a simple health pack that a player can pick up and use. This Object will delete itself once it is deleted. Please give any - 3 | // credit for using this code in your project. - 4 | // Nicholas Mallonee - 5 | // Unreal Engine 4.7.6 - 6 | // Sept. 6. 2015 - 7 | //--------------------------------------------------------------------------------------------------------------------------------------- 8 | 9 | //--------------------------------------------------------------------------------------------------------------------------------------- 10 | // Pregmas and Defines - 11 | //--------------------------------------------------------------------------------------------------------------------------------------- 12 | #pragma once 13 | 14 | //--------------------------------------------------------------------------------------------------------------------------------------- 15 | // Libraries and Includes - 16 | //--------------------------------------------------------------------------------------------------------------------------------------- 17 | #include "GameFramework/Actor.h" 18 | #include "HealthPack.generated.h" 19 | 20 | //--------------------------------------------------------------------------------------------------------------------------------------- 21 | // Class Information - 22 | //--------------------------------------------------------------------------------------------------------------------------------------- 23 | UCLASS() 24 | class C_PLUS_PLAYGROUND_API AHealthPack : public AActor 25 | { 26 | GENERATED_BODY() 27 | 28 | // -- Public Information -- Constructors and Engine Events -- // 29 | public: 30 | AHealthPack(); // Default Constructor 31 | 32 | AHealthPack(const FObjectInitializer& ObjectInitializer); // Argumented Constructor 33 | 34 | virtual void BeginPlay() override; // Begin Play Event 35 | 36 | virtual void Tick( float DeltaSeconds ) override; // Frame Tick Event 37 | 38 | virtual void ReceiveActorBeginOverlap(class AActor* Other) override; // Engine Event for Overlap events 39 | 40 | void removeFromWorld(); // Hides and then deletes this actor from the game worl 41 | 42 | // -- Private Information -- Player Handles and Checks -- // 43 | private: 44 | bool canBePickedUP(class AC_Plus_PlaygroundCharacter* Other); // checks if the player is alive and can pick this up 45 | 46 | void handlePickUp(class AC_Plus_PlaygroundCharacter* Other); // handles giving the player health, or other things 47 | 48 | void handleEffects(); // handles the effects or sounds 49 | 50 | 51 | // -- Protected Information -- Health Pack's Collision, Health, and particle -- // 52 | protected: 53 | float health; // Holds the amount of health it can give to the player 54 | 55 | UPROPERTY(EditDefaultsOnly, Category = "Caught Particle") 56 | UParticleSystem* ourParticle; // Holds the particle that will spawn when the player picks this up 57 | 58 | UBoxComponent* collisionComp; // Holds the bounds in which this object can interact with the player 59 | }; 60 | -------------------------------------------------------------------------------- /Basic_Procedural_Forest_Controller_HeaderFile: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------------------------------------- 2 | // This controls the spawning of a proc. forest. - 3 | // This is a simple, simple, simple example of what procedural spawing is. In a normal example, you might generate a seed and use that to - 4 | // Determine what path to take(Will do a tutorial on this at a later date). - 5 | // Please Give Credit for any code used. Thanks, - 6 | // Nicholas Mallonee - 7 | // Unreal Engine 4 - 8 | // Version 4.7.6 - 9 | // Date: 4.8.15 -- Day, Month, Year - 10 | //---------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | 13 | //---------------------------------------------------------------------------------------------------------------------------------------------- 14 | // Prama's and Defines - 15 | //---------------------------------------------------------------------------------------------------------------------------------------------- 16 | #pragma once 17 | 18 | //---------------------------------------------------------------------------------------------------------------------------------------------- 19 | // Libraries and Includes - 20 | //---------------------------------------------------------------------------------------------------------------------------------------------- 21 | #include "GameFramework/Actor.h" // Library we are inheirting 22 | #include "Proc_tree.h" // the object we are going to spawn 23 | #include "Forest_Controller.generated.h" // This classes header file 24 | 25 | 26 | //---------------------------------------------------------------------------------------------------------------------------------------------- 27 | // Forest Controller Class - 28 | //---------------------------------------------------------------------------------------------------------------------------------------------- 29 | UCLASS() 30 | class HARDCORE_API AForest_Controller : public AActor 31 | { 32 | GENERATED_BODY() 33 | 34 | // -- Public Information -- Constructors and engine events -- // 35 | public: 36 | AForest_Controller(); // The Default Constructor 37 | 38 | virtual void BeginPlay() override; // Driver for our proc spawning method 39 | 40 | virtual void Tick( float DeltaSeconds ) override; // Frame Tick event 41 | 42 | // -- Private Information -- Spawning Methods and Checks -- // 43 | private: 44 | float generateX(float oldUsedX); // Generates an X coord to use 45 | 46 | float generateY(float oldUsedY); // Generates a Y coord to use 47 | 48 | bool isUsed(TArray &oldArray, float numCheck); // Checks if the value has been used before, by testing an array 49 | 50 | float distanceBetween(float inOne, float inTwo); // Checks the distance betweem points 51 | 52 | bool isOneGreater(float inOne, float inTwo); // Checks if one value is greater than another 53 | 54 | // -- private inforation -- Data types and containers -- // 55 | private: 56 | 57 | TArray oldX; // An Array to Hold all the old Xs 58 | 59 | TArray oldY; // An Array to Hold all the Old ys 60 | 61 | float newX; // holds the new X 62 | 63 | float newY; // holds the new Ys 64 | 65 | 66 | // -- Protected Informatin -- Spawned Objects -- // 67 | protected: 68 | UPROPERTY(EditDefaultsOnly, Category = "Possible Object One") 69 | TSubclassOf treeOne; // First Possible object 70 | 71 | UPROPERTY(EditDefaultsOnly, Category = "Possible Object Two") 72 | TSubclassOf treeTwo; // Second Possible Object 73 | 74 | UPROPERTY(EditDefaultsOnly, Category = "Possible Object Three") 75 | TSubclassOf treeThree; // third Possible Object 76 | }; 77 | -------------------------------------------------------------------------------- /Light_Switch_CPPFile: -------------------------------------------------------------------------------- 1 | // This is the cpp file for the simple light switch 2 | 3 | 4 | 5 | 6 | 7 | //--------------------------------------------------------------------------------------------------------------------------------------- 8 | // Preagmas and Defines - 9 | //--------------------------------------------------------------------------------------------------------------------------------------- 10 | #include "HauntedHouseSim.h" 11 | #include "Resources/Player/PlayerCharacter.h" 12 | #include "Engine.h" 13 | #include "FuseBox.h" 14 | 15 | 16 | //--------------------------------------------------------------------------------------------------------------------------------------- 17 | // Constructors - 18 | //--------------------------------------------------------------------------------------------------------------------------------------- 19 | AFuseBox::AFuseBox() // -- Default Consturctor -- // 20 | { 21 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 22 | PrimaryActorTick.bCanEverTick = false; 23 | } 24 | 25 | AFuseBox::AFuseBox(const FObjectInitializer& ObjectInitializer) // -- Argumented Constructor -- // 26 | : Super(ObjectInitializer) 27 | { 28 | // tick set up 29 | PrimaryActorTick.bCanEverTick = false; 30 | 31 | // mesh set up 32 | ourMesh = CreateDefaultSubobject(TEXT("Our Mesh")); 33 | ourMesh->SetEnableGravity(false); 34 | ourMesh->SetSimulatePhysics(false); 35 | RootComponent = ourMesh; 36 | 37 | // collision comp set up 38 | collisionComp = CreateDefaultSubobject(TEXT("Collision Comp")); 39 | collisionComp->SetRelativeLocation(FVector(0.f, 60.f, 0.f)); 40 | collisionComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly); 41 | collisionComp->SetSphereRadius(60.f); 42 | collisionComp->AttachParent = RootComponent; 43 | 44 | // light set-up 45 | ourLight = CreateDefaultSubobject(TEXT("Our Light")); 46 | ourLight->SetRelativeLocation(FVector(100.f, 150.f, 120.f)); 47 | ourLight->SetVisibility(true); 48 | ourLight->SetCastShadows(true); 49 | ourLight->SetIntensity(10000.f); 50 | ourLight->SetAttenuationRadius(5000.f); 51 | ourLight->AttachParent = RootComponent; 52 | 53 | // lights current state set 54 | bIsOn = true; 55 | } 56 | 57 | //--------------------------------------------------------------------------------------------------------------------------------------- 58 | // Engine Events - 59 | //--------------------------------------------------------------------------------------------------------------------------------------- 60 | void AFuseBox::BeginPlay() // -- Begin Play Event -- // 61 | { 62 | Super::BeginPlay(); 63 | 64 | //setUpBox(); 65 | } 66 | 67 | void AFuseBox::Tick( float DeltaTime ) // -- Frame Tick Event -- // 68 | { 69 | Super::Tick( DeltaTime ); 70 | } 71 | 72 | void AFuseBox::ReceiveActorBeginOverlap(class AActor* Other) // -- Overlap Begin Event -- // 73 | { 74 | if (Other != NULL) 75 | { 76 | //if (isPlayer(Cast(Other))) 77 | //{ 78 | // ourPlayer = Cast(Other); 79 | 80 | // setPlayerNear(true); 81 | 82 | // // ** DEBUG ** // 83 | // GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Green, TEXT("Player is in the overlap :: Fuse Box")); 84 | //} 85 | } 86 | 87 | } 88 | 89 | void AFuseBox::ReceiveActorEndOverlap(class AActor* Other) // -- Overlap End Event -- // 90 | { 91 | if (Other != NULL) 92 | { 93 | //if (isPlayer(Cast(Other))) 94 | //{ 95 | // ourPlayer = NULL; 96 | 97 | // setPlayerNear(false); 98 | 99 | // // ** DEBUG ** // 100 | // GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("Player is leaving the overlap :: Fuse box")); 101 | //} 102 | } 103 | } 104 | 105 | 106 | //--------------------------------------------------------------------------------------------------------------------------------------- 107 | // OutSide Accessors and Mutators - 108 | //--------------------------------------------------------------------------------------------------------------------------------------- 109 | void AFuseBox::toggleLight() 110 | { 111 | GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Yellow, TEXT("Toggling Fuse Box :: Fuse Box")); 112 | 113 | if (bIsOn == true) 114 | { 115 | bIsOn = false; 116 | ourLight->SetVisibility(false); 117 | } 118 | else 119 | { 120 | bIsOn = true; 121 | ourLight->SetVisibility(true); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Timer_Example_Spawner_CPP_File: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------- 2 | // This is a simple timer example. This asset will simply spawn a number of "Orbs" around the origin of the game - 3 | // world. Once the selected number of assets is completed it will unbind the timer handle and wait to be removed by - 4 | // the end play event. You can freely use this example in your unreal engine projects! Just let me know if you - 5 | // have any questioms. - 6 | // - 7 | // Nicholas Mallonee - 8 | // Unreal Engine 4.7.6 -> 4.10.1 - 9 | //------------------------------------------------------------------------------------------------------------------- 10 | 11 | //------------------------------------------------------------------------------------------------------------------- 12 | // Libraries and Includes - 13 | //------------------------------------------------------------------------------------------------------------------- 14 | #include "AI_Playground.h" // The project this asset is in. 15 | #include "OrbSpawner.h" // This classes header file. 16 | 17 | //----------------------------------------------------------------------------------------------------------------- 18 | // Constructor - 19 | //----------------------------------------------------------------------------------------------------------------- 20 | AOrbSpawner::AOrbSpawner() 21 | { 22 | PrimaryActorTick.bCanEverTick = false; // We do not need this actor to tick, since its operations 23 | // are handled by the timer we bind in begin play 24 | 25 | spawnerCount = 3; // The Default amount of times this actor runs its timer 26 | } 27 | 28 | //----------------------------------------------------------------------------------------------------------------- 29 | // Engine Events - 30 | //----------------------------------------------------------------------------------------------------------------- 31 | void AOrbSpawner::BeginPlay() 32 | { 33 | Super::BeginPlay(); 34 | 35 | // Clear any running timer that may be in the world. 36 | // This may cause issues with multiple actors with the same method.. 37 | GetWorld()->GetTimerManager().ClearTimer(spawnTimerHandler); 38 | 39 | // You can use this if the one above does cause issues. 40 | // This clears any timers for this specific object 41 | //GetWorld()->GetTimerManager().ClearAllTimersForObject(this); 42 | 43 | 44 | // Set the timer to run every 1.25f of a second 45 | // This method binds our spawn time handler to THIS specific 46 | // object, and will call the handle spawn method by reference 47 | // every 1.25 seconds. 48 | // The "TRUE" at the end, lets this handle know it needs to call 49 | // the method again. 50 | GetWorld()->GetTimerManager().SetTimer(spawnTimerHandler, this, &AOrbSpawner::handleSpawn, 1.25f, true); 51 | } 52 | 53 | void AOrbSpawner::Tick( float DeltaTime ) 54 | { 55 | Super::Tick( DeltaTime ); 56 | 57 | 58 | // WE DONT NEED TO LOAD THIS METHOD SINCE WE ARE USING A TIMER! 59 | } 60 | 61 | void AOrbSpawner::EndPlay(const EEndPlayReason::Type EndPlayReason) 62 | { 63 | Super::EndPlay(EndPlayReason); 64 | 65 | // ** NOTE ** 66 | // DO NOT CLEAR THE TIMER HERE! 67 | // IT WILL CRASH YOUR PROJECT AND YOUR LIFE!!! 68 | // IT WILL SHOW A FALSE ERROR! 69 | // IT TOOK ME 3 DAYS TO TRACK THIS BUG DOWN ON 70 | // ANOTHER PROJECT!!!!! 71 | } 72 | 73 | //----------------------------------------------------------------------------------------------------------------- 74 | // Spawning Methods and Timer Handles - 75 | //----------------------------------------------------------------------------------------------------------------- 76 | void AOrbSpawner::handleSpawn() // -- Handles the logic tree -- // 77 | { 78 | if (spawnerCount > 0) // If we can still spawn something 79 | { // spawn the orb / object 80 | spawnOrb(); 81 | } 82 | else // if we can not spawn somthing 83 | { // remove the timer handle from this 84 | cleanUpTimer(); // Object. 85 | } 86 | } 87 | 88 | void AOrbSpawner::spawnOrb() 89 | { 90 | // Make sure the world exists 91 | UWorld* const world = GetWorld(); 92 | 93 | // if the world exists try to spawn the object 94 | if (world) 95 | { 96 | // Generate an X to use for the x and y axis. 97 | float x = FMath::RandRange(-270, 270); 98 | 99 | // generate a vector to use. 100 | FVector loc = FVector(x, x, 500.f); 101 | 102 | // set the spawn params 103 | FActorSpawnParameters spawnParams; 104 | spawnParams.Owner = this; 105 | spawnParams.Instigator = Instigator; 106 | 107 | // Spawn the actor 108 | GetWorld()->SpawnActor(ourOrb, loc, FRotator::ZeroRotator, spawnParams); 109 | } 110 | 111 | // reduce the count fo the spawn counter 112 | spawnerCount--; 113 | } 114 | 115 | void AOrbSpawner::cleanUpTimer() 116 | { 117 | // Clear up this timer on this object 118 | GetWorld()->GetTimerManager().ClearTimer(spawnTimerHandler); 119 | } 120 | -------------------------------------------------------------------------------- /Basic_Spawner_Controller_Code_CPP_File: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------------------------------------------------------- 2 | // This class generates the spawn solutions for any power-ups that will affect the player during the game time. - 3 | // This is similar to the falling object controller, however it is more time sensitive. It will need to check - 4 | // the time between spawns to make sure that is universal and never fails. - 5 | // Nicholas Mallonee - 6 | // Unreal Engine 4.7.6 - 7 | //--------------------------------------------------------------------------------------------------------------------------------------- 8 | 9 | 10 | //--------------------------------------------------------------------------------------------------------------------------------------- 11 | // Libraries and Includes - 12 | //--------------------------------------------------------------------------------------------------------------------------------------- 13 | #include "Catch_Me_If_You_Can.h" // The Game or app this is in 14 | #include "PowerUp_Controller.h" // This classes header file 15 | #include "Engine.h" // Used for debug messages 16 | 17 | 18 | //--------------------------------------------------------------------------------------------------------------------------------------- 19 | // Class Constructors - 20 | //--------------------------------------------------------------------------------------------------------------------------------------- 21 | APowerUp_Controller::APowerUp_Controller() // -- Default Constructor -- // 22 | { 23 | // -- Engine Events for this class -- // 24 | PrimaryActorTick.bCanEverTick = true; 25 | this->SetActorTickEnabled(true); 26 | } 27 | 28 | APowerUp_Controller::APowerUp_Controller(const FObjectInitializer& ObjectInitializer) // -- Argumented Constructor -- // 29 | : Super(ObjectInitializer) 30 | { 31 | // -- Allow this actor to call the tick event -- // 32 | PrimaryActorTick.bCanEverTick = true; // allow this actor to call the tick method 33 | this->SetActorTickEnabled(true); // Force this actor to enable the tick 34 | 35 | currentTime = 0.f; // Set the current time to 0.f seconds, so its not some random number 36 | xCord = 0.f; // set the Xcord we will spawn at to 0.f, so its not some random number 37 | 38 | // Set vector and Rototor to zero 39 | ourRotation.ZeroRotator; // Set our rotator to 0: 0 roll, 0 pitch, and 0 yaw 40 | ourLoc.X = 0.f; // set our vector to 0 in the x axis(left and right) 41 | ourLoc.Y = 100.f; // set our vector to 100 in the y axis(forward and backward) 42 | ourLoc.Z = 800.f; // set our vector to 800 in the z axis(up and down) 43 | } 44 | 45 | 46 | //--------------------------------------------------------------------------------------------------------------------------------------- 47 | // Engine Events - 48 | //--------------------------------------------------------------------------------------------------------------------------------------- 49 | void APowerUp_Controller::BeginPlay() // -- Begin Play Event -- // 50 | { 51 | // overrides the super class(AActor in this case) method, begin play 52 | Super::BeginPlay(); 53 | 54 | // Debug message to know the object is alive and in the world 55 | GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, TEXT("We are alive")); 56 | 57 | } 58 | 59 | void APowerUp_Controller::Tick( float DeltaTime ) // -- Frame Tick Event -- // 60 | { 61 | // overrides the super class(AActor) method, tick 62 | Super::Tick( DeltaTime ); 63 | 64 | // take the current time and increment it by 1, and multiply it by the delta time 65 | currentTime = currentTime + 1 * DeltaTime; 66 | 67 | // debug message to display the current time 68 | FString ourString = FString::SanitizeFloat(currentTime); 69 | 70 | // printing the debug message to the game world 71 | GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Green, TEXT("Our Current Time: ") + ourString); 72 | 73 | // if the current time is greater or equal to 2, then do the following... 74 | if (currentTime >= 2.f) 75 | { 76 | // gen a new X 77 | xCord = generateX(DeltaTime); 78 | 79 | // set the x in the location 80 | ourLoc.X = xCord; 81 | 82 | // Create Spawn params 83 | FActorSpawnParameters spawnParams; 84 | 85 | // who did the spawn, and we are say this controller did 86 | spawnParams.Owner = this; 87 | 88 | // Set the instigator to default 89 | spawnParams.Instigator = Instigator; 90 | 91 | // spawn the object now 92 | APowerUP_Parent* ourNewObject = GetWorld()->SpawnActor(ourSpawningObject, ourLoc, ourRotation, spawnParams); 93 | 94 | // debug 95 | GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::White, TEXT("We spawned an object")); 96 | 97 | // currentTime back to 0 98 | currentTime = 0.f; 99 | } 100 | } 101 | 102 | // This method will generate a new x value to spawn an object into th game world 103 | float APowerUp_Controller::generateX(float DeltaSeconds) // -- Generate a new number -- // 104 | { 105 | // create a variable in memory to pass back a float value for us to use, set it to 0.000000000 106 | float passBack = 0.f; 107 | 108 | // give it a new number, using the FMath class using the Rand Range method 109 | // generates a number between -300 and 300 110 | passBack = FMath::RandRange(-300, 300); 111 | 112 | // take that number we just generated and add the small number delta seconds is to it 113 | passBack = passBack + DeltaSeconds; 114 | 115 | // Return the newly generated number back to the tick method 116 | return passBack; 117 | } 118 | -------------------------------------------------------------------------------- /Basic_Health_Pack_CPP: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------------------------------------------------------------- 2 | // This is a simple health pack that a player can pick up and use. This Object will delete itself once it is deleted. Please give any - 3 | // credit for using this code in your project. - 4 | // Nicholas Mallonee - 5 | // Unreal Engine 4.7.6 - 6 | // Sept. 6. 2015 - 7 | //--------------------------------------------------------------------------------------------------------------------------------------- 8 | 9 | //--------------------------------------------------------------------------------------------------------------------------------------- 10 | // Libraries and Includes - 11 | //--------------------------------------------------------------------------------------------------------------------------------------- 12 | #include "C_Plus_Playground.h" // Game or project this is included with 13 | #include "C_Plus_PlaygroundCharacter.h" // Players Character that can use this health pack 14 | #include "Engine.h" // Engine header file for debug messages 15 | #include "HealthPack.h" // This Classes header file 16 | 17 | //--------------------------------------------------------------------------------------------------------------------------------------- 18 | // Constructors - 19 | //--------------------------------------------------------------------------------------------------------------------------------------- 20 | AHealthPack::AHealthPack() // -- Default Constructor -- // 21 | { 22 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 23 | PrimaryActorTick.bCanEverTick = true; 24 | 25 | // health sets 26 | health = 40.f; 27 | } 28 | 29 | AHealthPack::AHealthPack(const FObjectInitializer& ObjectInitializer) // -- Argumented Constructor -- // 30 | { 31 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 32 | PrimaryActorTick.bCanEverTick = true; 33 | 34 | // health sets 35 | health = 40.f; // health is set to a default value of 40.f 36 | 37 | // collision set up 38 | collisionComp = ObjectInitializer.CreateDefaultSubobject(this, TEXT("Collision Comp")); 39 | FVector boxSize = FVector(100.f, 100.f, 100.f); // Create a FVector to set this collisionComps Size 40 | collisionComp->SetBoxExtent(boxSize); // Set the box size using a FVECTOR 41 | collisionComp->SetEnableGravity(true); // Set this box to be effected by gravity 42 | collisionComp->SetSimulatePhysics(true); // Set this box to be effected by basic physics 43 | RootComponent = collisionComp; // Set this box as the root component in the scene root 44 | } 45 | 46 | //--------------------------------------------------------------------------------------------------------------------------------------- 47 | // Engine Events - 48 | //--------------------------------------------------------------------------------------------------------------------------------------- 49 | void AHealthPack::BeginPlay() // -- Begin Play Event -- // 50 | { 51 | Super::BeginPlay(); 52 | 53 | } 54 | 55 | void AHealthPack::Tick( float DeltaTime ) // -- Frame Tick Event -- // 56 | { 57 | Super::Tick( DeltaTime ); 58 | } 59 | 60 | void AHealthPack::ReceiveActorBeginOverlap(class AActor* Other) // -- Overlap Event -- // 61 | { 62 | if (Other != NULL) // if the other is NOT null 63 | { 64 | if (canBePickedUP(Cast(Other))) // if the player has health GREATER THAN 0.f 65 | { 66 | handlePickUp(Cast(Other)); // Give the player health using an accessor method on the player 67 | 68 | handleEffects(); // handle(play) any effects or sounds 69 | 70 | removeFromWorld(); // hide and then mark this actor for the next deletion cycle 71 | } 72 | } 73 | } 74 | 75 | void AHealthPack::removeFromWorld() // -- Remove From World Method -- // 76 | { 77 | RootComponent->GetChildComponent(0)->SetHiddenInGame(true); // Hide the static mesh of the box 78 | 79 | K2_DestroyActor(); // mark this object to be deleted 80 | } 81 | 82 | //--------------------------------------------------------------------------------------------------------------------------------------- 83 | // Player Interaction Handling and Checks - 84 | //--------------------------------------------------------------------------------------------------------------------------------------- 85 | bool AHealthPack::canBePickedUP(class AC_Plus_PlaygroundCharacter* Other) // -- Can Be Picked Up Method -- // 86 | { 87 | bool flag = false; // Create a flag and assume that the player can not pick it up 88 | 89 | if (Other != NULL && Other->isAlive()) // if the player is not null, and the player has returned they can pick it up 90 | { 91 | flag = true; // set the flag to true 92 | } 93 | 94 | return flag; // return the result of the test 95 | } 96 | 97 | void AHealthPack::handlePickUp(class AC_Plus_PlaygroundCharacter* Other) // -- Handle Pick Up Method -- // 98 | { 99 | if (Other != NULL) // If the player(Other) is not null 100 | { 101 | // ** DEBUG ** // 102 | GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Magenta, TEXT("Players Health has been modified! ")); 103 | 104 | Other->addHealth(this->health); // use the accessor method on the player to pass them health from this object 105 | } 106 | } 107 | 108 | void AHealthPack::handleEffects() // -- Handle Effects -- // 109 | { 110 | FVector ourLoc = this->GetActorLocation(); // Get this actors location in world 111 | FRotator ourRot = FRotator::ZeroRotator; // Create a rotator and set it to (0.f, 0.f, 0.f) 112 | 113 | UGameplayStatics::SpawnEmitterAtLocation(this, ourParticle, ourLoc, ourRot); // spawn a particle at the location 114 | } 115 | 116 | -------------------------------------------------------------------------------- /Basic_Procedural_Forest_Controller_CPPFile: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------------------------------------------------------------------------------- 2 | // This controls the spawning of a proc. forest. - 3 | // This is a simple, simple, simple example of what procedural spawing is. In a normal example, you might generate a seed and use that to - 4 | // Determine what path to take(Will do a tutorial on this at a later date). - 5 | // Please Give Credit for any code used. Thanks, - 6 | // Nicholas Mallonee - 7 | // Unreal Engine 4 - 8 | // Version 4.7.6 - 9 | // Date: 4.8.15 -- Day, Month, Year - 10 | //---------------------------------------------------------------------------------------------------------------------------------------------- 11 | 12 | 13 | //---------------------------------------------------------------------------------------------------------------------------------------------- 14 | // Libaries and Includes - 15 | //---------------------------------------------------------------------------------------------------------------------------------------------- 16 | #include "HardCore.h" // The game that this is included in 17 | #include "Forest_Controller.h" // This classes Header file 18 | 19 | 20 | //---------------------------------------------------------------------------------------------------------------------------------------------- 21 | // Constructors and Engine Events - 22 | //---------------------------------------------------------------------------------------------------------------------------------------------- 23 | AForest_Controller::AForest_Controller() // -- The Default Constructors -- // 24 | { 25 | // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. 26 | PrimaryActorTick.bCanEverTick = false; 27 | 28 | 29 | // -- Value Sets -- // 30 | newX = 0.f; 31 | newY = 0.f; 32 | 33 | // -- Array Set-up -- // 34 | oldX.SetNum(100); 35 | oldY.SetNum(100); 36 | } 37 | 38 | void AForest_Controller::BeginPlay() // -- The Begin Play Event -- The Driver of this class -- // 39 | { 40 | Super::BeginPlay(); 41 | 42 | 43 | // driver function, this will run 100 times on begin play. 44 | // starts at 0 and moves to 99 45 | for (int32 i = 0; i < 100; i++) 46 | { 47 | // generate a x for us to use 48 | newX = generateX(newX); 49 | 50 | // generate a y for use to use 51 | newY = generateY(newY); 52 | 53 | // Add the X to the array at the ith slot 54 | oldX[i] = newX; 55 | 56 | // add the Y to the array at the i slot 57 | oldY[i] = newY; 58 | 59 | // check if the world exits 60 | const UWorld* world = GetWorld(); 61 | 62 | // if the world does exist 63 | if (world) 64 | { 65 | // create spawn params 66 | FActorSpawnParameters spawnParams; 67 | spawnParams.Owner = this; // Who spawned this object 68 | spawnParams.Instigator = Instigator; // Who Can do damage to this object 69 | 70 | // Create a vector based on our code 71 | FVector newVec; // Create a new Vector for us to use 72 | newVec.Set(newX, newY, 145.f); // set the locatin to the newX, newY, and 145.f units above the ground 73 | 74 | // spawn the object 75 | int32 num = FMath::RandRange(0, 2); // pick a number between 0 and 2( 0 , 1, or 2) 76 | 77 | // flow control to pick an object 78 | if (num == 0) // if it is 0 79 | { 80 | AActor* newActor = GetWorld()->SpawnActor(treeOne, newVec, FRotator::ZeroRotator, spawnParams); 81 | } 82 | else if (num == 1) // if it is 1 83 | { 84 | AActor* newActor = GetWorld()->SpawnActor(treeTwo, newVec, FRotator::ZeroRotator, spawnParams); 85 | } 86 | else if (num == 2) // if it is 2 87 | { 88 | AActor* newActor = GetWorld()->SpawnActor(treeThree, newVec, FRotator::ZeroRotator, spawnParams); 89 | } 90 | } 91 | } 92 | } 93 | 94 | void AForest_Controller::Tick( float DeltaTime ) // -- Frame Tick Event -- // 95 | { 96 | Super::Tick( DeltaTime ); 97 | 98 | // we dont need this since we are not worring about player movement 99 | } 100 | 101 | //------------------------------------------------------------------------------------------------------------------------------- 102 | // Spawn Point Gens - 103 | //------------------------------------------------------------------------------------------------------------------------------- 104 | float AForest_Controller::generateX(float oldUsedX) // - Generates a new X coord -- // 105 | { 106 | float passBack = 0.f; // init a varaible to the origin 107 | 108 | passBack = FMath::RandRange(-5000, 5000); // generate a number between -5000 and 5000 unreal units 109 | 110 | passBack = passBack + oldUsedX; // set that number to itself plus the old number 111 | 112 | if (passBack < -5000.f || passBack > 5000.f) // if the number is less that 5000 or greater than 5000 113 | { // send a recursive call to create a new one 114 | passBack = generateX(oldUsedX); 115 | } 116 | 117 | if (!isUsed(oldX, passBack)) // if the number was used at all, make a recursive call to 118 | { // generate a new one for use to use 119 | passBack = generateX(oldUsedX); 120 | } 121 | 122 | return passBack; // return the result 123 | } 124 | 125 | float AForest_Controller::generateY(float oldUsedY) // -- Generates a new y coord -- // 126 | { 127 | float passBack = 0.f; // init a variable to the origin 128 | 129 | passBack = FMath::RandRange(-5000, 5000); // choose a number between -5000 and 5000 unreal units 130 | 131 | passBack = passBack + oldUsedY; // add the old number to that newly generated number 132 | 133 | if (passBack < -5000.f || passBack > 5000.f) // if that number is less than -5000 or greater than 5000 134 | { // make a recursive call to try and generate a new number and pass it back 135 | passBack = generateY(oldUsedY); 136 | } 137 | 138 | if (!isUsed(oldY, passBack)) // if that number has been used at all 139 | { // make a recursive call to try and generate a new Y 140 | passBack = generateY(oldUsedY); 141 | } 142 | 143 | return passBack; // return the result 144 | } 145 | 146 | bool AForest_Controller::isUsed(TArray &oldArray, float numCheck) // -- Checks to see if this was used -- // 147 | { 148 | bool flag = true; // Create a flag and set it to it being valid and not used 149 | 150 | for (int32 i = 0; i < oldArray.Num(); i++) // create a for loop to process the array and cycle through each slot 151 | { 152 | if (distanceBetween(oldArray[i], numCheck) < 50.f) // if the array's slot number and the newly generated number are less 153 | { // than 50 units apart trip the flag to false 154 | flag = false; 155 | } 156 | } 157 | 158 | return flag; // return the result of the test 159 | } 160 | 161 | float AForest_Controller::distanceBetween(float inOne, float inTwo) // -- Checks the distance between points -- // 162 | { 163 | float passBack = 0.f; // init a variable to the origin 164 | 165 | bool flag = isOneGreater(inOne, inTwo); // check which number is greater and catch the result 166 | 167 | if (flag == true) // if the result was true, that the first number is greater 168 | { 169 | passBack = inOne - inTwo; // set the distance between to the first number minus the second 170 | } 171 | else // if the result was false, that the first number was smaller 172 | { 173 | passBack = inTwo - inOne; // set the distance between to the second number minus the first 174 | } 175 | 176 | return passBack; // return the result of the distance between 177 | } 178 | 179 | bool AForest_Controller::isOneGreater(float inOne, float inTwo) // -- Checks to see which number is greater -- // 180 | { 181 | bool flag = true; // assume the first number is greater 182 | 183 | if (inOne <= inTwo) // if the first number is less than or equal to the second 184 | { 185 | flag = false; // trip the flag to false 186 | } 187 | 188 | return flag; // return the result 189 | } 190 | --------------------------------------------------------------------------------