Unreal Engine 4
Unreal labs will be in e-study format. Please solve one practice each week, and afterward, the Unreal and Unreal networking labs can be submitted at the same time.
Setting up Unreal
- Download Epic launcher from here: https://www.epicgames.com/store/en-US/ (Blue "Get Epic Games" button on right corner)
- Navigate to Unreal Engine -> Library tab and add Unreal version 4.27 (currently installed in the classroom)
- Create a new project by pressing Launch -> to choose Games -> First Person. Select the project location and leave everything else to default. Press Create project and try to run it.
- If you use the classroom computer, the Epic launcher might not work correctly. Instead, open the UE4.Editor.exe located in D:\UE_4.27\Engine\Binaries\Win64.
Unreal Introduction
This is a class diagram of Unreal's base classes:
![](https://courses.cs.ut.ee/2024/ge/fall/Main/Unreal?action=download&upname=UnrealClasses.png)
Useful links:
Practice 1
Goal: create a grenade launcher by adding explosions to the first person template.
- Create a new project using First Person Template with the following settings:
![](https://courses.cs.ut.ee/2024/ge/fall/Main/Unreal?action=download&upname=UnrealNewProject.png)
- Create and use a custom GameMode blueprint.
- Check the FirstPersonProjectile blueprint and try to describe what is it doing.
- Spawn the explosion effect from the StarterContent whenever the projectile hits something (Hint: Use Spawn Emitter at Location).
- Make the projectile behave similarly when hit hits the environment or the cube.
- Make the explosion configurable through variables.
- Make the explosion apply an impulse to all the objects in a radius.
- Add additional collision component with OverlapAll collision preset.
- Loop through the overlapping actors and apply a radial impulse to each one of them.
Practice 2
Goal: make a time based jumping puzzle.
- Create a BP_ExtractionZone actor.
- Add UBoxComponent which responds to the pawn overlap only
- Call a custom CompleteMission event in your custom game mode blueprint when the player enters. Pass the InstigatorPawn as its argument and disable its input.
- Play sound when the mission is completed (you can use the Unreal engine sound file).
- Add UDecalComponent with similar size to the UBoxComponent. Rotate it so that it shows the image on the floor.
- Create new WBP_GameOver (widget blueprint)
- Add a text "Mission Complete" anchored to the centre.
- Create this widget in the game mode when the mission is completed and add it to the viewport.
- Create a new Actor BP_SpectatingViewport with a static mesh with MatineeCamera that is hidden in-game.
- Add the actor in the scene, right-click -> pilot and move it to get a good overview of the scene.
- On game over, find the camera actor and get the PlayerController and use the SetViewTargetwithBlend function to blend the view to the new point.
- Try different blend functions and times to make the transition smoother.
- Create WBP_HUD (widget) and add it to the viewport at the beginning of the game.
- Add method for setting the time value.
- Add a timer to the GameMode that ticks every second decrease the remaining time and updates the widget.
- End the game with "Mission Failed" text when the time reaches zero.
- Create a launchpad that uses the LaunchCharacter function in your character class to launch the player in the air.
- Define variables for LaunchStrength (1500f) and LaunchPitchAngle (35f).
- On launch get the launchpad actor rotation, and create a LaunchVelocity vector by increasing its pitch and multiplying the vector by the LaunchStrength.
- Extra: Launch other dynamic objects too when they touch the launch pad.
Practice 3
Goal: make a lever and door system.
- Download meshes: Attach:DoorAndLever.zip
- Import them to a Meshes folder without generating materials (Import all)
- Create a base material with a colour property
- Create different colour material instances
- Add coloured materials to the meshes
- Create a blueprint interfaces BI_Interactable
- Add interface function Interact.
- Add interface function CanInteract that returns boolean.
- Add interface function Reset.
- Create a Lever actor BP_Lever that inherits BI_Interactable.
- Lever has two static meshes that open the door. (Included in fbx file)
- Add a line trace to the first person character tick event
- Use Camera world location and world rotation to calculate the line trace start and endpoints.
- Save the hovered Interactable to a variable.
- Call the interact method when E is pressed (you will have to configure E as an action key).
- Add a world space widget to the lever with the remaining time display.
- Create a new WBP_LeverScreen widget that scales with the screen and displays the remaining time. ** Try to use layouts to organize elements on the widget.
- Add Widget component to the BP_Lever and attach the WBP_LeverScreen.
- Create lever functionality
- When the lever is pressed, rotate the handle down using SetRelativeRotation.
- Extra: use Timeline node to rotate the handle over time.
- Add event dispatcher that dispatches an event when the lever is pressed.
- Add a second event dispatcher that dispatches an event when lever resets.
- Count the time and when it's up move the lever up again.
- Create a Door actor BP_Door. (World rotation has Get Forward Vector function)
- Door has two static mesh components that slide away when it's opened.
- Door has BI_Lever reference variable that is instance editable, assign the BP_Lever in the scene.
- Attach to the lever event dispatchers and open and close the door. Use the timeline to do it smoothly.
Practice 4
Goal: create collectable objects and level layout.
- Create a collectable actor with sphere mesh.
- Create a custom material for the sphere, that is glowing and the colour can be edited.
- When the player touches the actor, play a sound and decrease the counter on the UI.
- Don't destroy the actor but make it invisible and after a certain time, make it visible again.
- Count the number of collectables gathered on the HUD and only allow to end the level when all are collected.
- Use the Level Blueprint to randomly spawn the collectable objects to the world. (50 collectables)
- Use a Line Trace to place them on the ground.
- Create a Data table with name, colour, value and cooldown times.
- Use the Data table values to randomly assign the values to the collectables.
- Use BSP objects like doors and ramps to create a cool looking level layout.
Submission
If you do the Unreal Networking project as well, then you don't have to submit this project separately, because we will continue adding multiplayer support to the same project. The deadline for both UE projects is the same.
Submit a compiled version of your game (Windows 64 build). Zip your build folder into a single package and make sure that all the additional files (that were created when building the game) are also included in this package. Don't submit your source code.
Unfortunately, the file will be too large to directly upload here. Upload the file to your google drive or another file hosting platform. Write the sharing link to a txt file and submit this.
Deadline: Before exam TBA (23.59)