Assignment Goals

The primary goals of this assignment are:

  1. Do some user-level C++ coding typical of what would be done for a game.
  2. Get some experience tracking down information in a large codebase.

For this assignment, you'll be creating C++ Actor, which is UE4's base class for anything that can be placed in a scene. Your actor will build a maze using the randomized Prim's algorithm. In your constructor, you will create a USceneComponent as the root component for the actor, and an array of UStaticMeshComponent, each containing one plane object as a wall. In the BeginPlay function, you will run Prim's algorithm and remove walls to create the maze.

maze

Details

As with assignment 1, I've given some fairly explicit steps to help you along, but this time I'm expecting you to do a little more in terms of following and generalizing examples of certain functionality in the engine code or online.

Create a project

  1. This time, create a Basic Code C++ project (with no starter content) called assn2
    • Put it in top level of your git repository (alongside the Engine directory and your assn1 project directory).
    • Code projects placed there will be picked up by GenerateProjectFiles and show up when you open UE4 in your IDE
    • If you run the assn2 game project from Visual Studio/XCode, you can break and debug either in your code or in the engine code.
  2. Create a level/map called "assn2" and set it as your startup map (depending on where you find it in the UI, sometimes it says Level, sometimes it says Map. It's the same thing)

C++ actor

  1. Create a new C++ actor
    • Be careful, a C++ Actor is different from an Actor Component. The Actor Component is a component that can be used to add the same common behaivor to several actors.
    • Do this in the editor by right clicking in the Content window or with the"Add New" button.
    • UE4 will create a header and C++ file with starter code. Make sure the class it creates is derived from AActor.
  2. Test that you can place it in the scene
    • If you use disable optimization in your C++ file, you will be able to break and debug in your actor code:
      • "#pragma optimize( "", off )" for Visual Studio or "#pragma clang optimize off" for XCode,
    • You can also print log messages with UE4_LOG(LogTemp, Warning, TEXT("printf format"), ...)

Add a SceneComponent and StaticMeshComponent

  1. See Source/Editor/ComponentVisualizers/Private/Manipulator.cpp for an example of an actor with a USceneComponent and UStaticMeshComponent
  2. Add the USceneComponent for actor placement, and set it as the RootComponent
  3. Add a single UStaticMeshComponent so you can see if it's working.

Fixed-sized Grid of walls

  1. Load a plane
    • Find the "reference name" for the built-in plane Mesh. To do that, you can drag a plane into the scene, click the magnifying glass on its Static Mesh to find the static mesh in the content browser, then right click and choose "Copy Reference"
    • That's the name to use with FObjectFinder to load the plane mesh.
  2. Create a material with the "Two Sided" box checked.
    • Otherwise the plane will only be visible from one side.
    • Other than it being two-sided, it doesn't really matter what you make your material look like, though you'll want something with some variation for visibility.
    • Copy the reference name for that material to load it with FObjectFinder
  3. Use UStaticMeshComponent::SetWorldLocationAndRotation() to rotate it to vertical instead of horizontal and position it.
    • Search in for SetWorldLocationAndRotation in the UE4 code to find many examples of its use
  4. Once you have one plane working, load a grid of them. Use SetWorldLocationAndRotation to position them.
    • The grid and maze can have a fixed compile-time constant size.
    • Every UStaticMeshComponent created using CreateDefaultSubobject in your actor needs a unique name
      • See Plugins/Experimental/StereoPanorama/Source/StereoPanorama/Private/SceneCapturer.cpp for an example.

grid

Make your maze

  1. Implement the maze algorithm in your BeginPlay function
  2. Remove walls by removing their mesh with StaticMeshComponent->SetStaticMesh(nullptr)

Grad Students

Grad students only should add a dynamic size parameter to your class, tagged with UPROPERTY(EditAnywhere), and make any necessary changes to be able to take the maze grid size from that parameter.

Submission

For full credit, you must commit multiple times during your development.

Add an assn2.txt to the top directory. Tell us what works and what doesn't, and anything else you think we should know for grading. Include a link to video demonstrating your project.

Push to your repository, and tag your final commit with an assn2 tag.