Today I am working on Lessons 110 - 120.
As of this post I am currently on Lesson 115, but I will recap the previous lessons.
Lesson 110: Protecting From A Null Pointer
I improved my error handling by checking to ensure a PressurePlate actor is connected to the OpenDoor component, and logging an Error if it is not so that I can easily find the null pointer.
Lesson 111: Getting The Player To Open The Door
The door still had to have the player manually setup on the OpenDoor component for the actual functionality of opening the door to happen. This was resolved by updating the code to search the world for the PlayerController, and get the Pawn attached to the PlayerController component. Now I no longer need to worry about setting my player manually!
Lesson 112: Getting the Door To Close
Thanks to some forward thinking on my part, I already had setup most of the code needed for this functionality to happen. I strayed from the two function method used by the instructor and instead updated my OpenDoor function to a more generic MoveDoor function. Then using If statements based on if the player is inside or outside the collision volume (PressurePlate), I set the TargetYaw to either OpenYaw or ClosedYaw (2 exposed properties on the OpenDoor component).Some additional exposed properties were added as well to give a ton of control to the designer (I will cover this in a second)
Lesson 113: Using GetTimeSeconds()
In this lesson we learned how to access the global time from the start of the game. Fantastic, now I can factor things based on time with just some simple math. Following along with the instructor I created a delay for closing the door. Being that I needed to do a good amount of play testing to get the door to almost make you think you can escape before it closed on you, I exposed this property to the OpenDoor component as well.
Lesson 114: Designer Friendly Components
As a long time developer who has worked with many different teams of people I am pretty used to exposing variables (properties) for easy tweaking. I had already been exposing every reasonable property that I found myself tweaking multiple times. Additionally I decided to add a few more exposed properties such as separate door movement speeds based on if you are opening or closing the door. As well as a Boolean that determines if the door is able to close at all, meaning once the door opens it stays open! As a bonus I found out how to disable editing of variables related to closing the door if the door can not be closed.
UPROPERTY(EditAnywhere, meta=(EditCondition="bCanClose"))
Lesson 115: Grabbing System Overview
We are starting the work on creating a grabbing system for picking up actors and moving them around the level! See below for some of my thoughts on ways I could go about making the grabbing, and weight system.
Think critically about how you would go about allowing a player pawn to pickup other objects and move them around the world.
1. When a player approaches an actor that can be picked up, it should be highlighted with an outline color.
2. The player then presses, and holds the left mouse button to grab and hold onto said actor.
3. The actor will go to the center of the players camera, and its collision will be turned off temporarily.
4. When letting go of the actor its collision will be turned back on and it will be released from the pawn.
5. The pressure plate will need to have a component made for it that checks the total weight within the collision volume against a designer set required weight.
6. When the weight limit is met the door connected to the pressure plate will open.
How to determine weight?
1. All grabbable actor within a room are apart of an array set on the pressure plate, all of them would be required within the collision volume to activate the pressure plate
2. Weight values are given to all grabbable actors and a total weight is added together based on all grabbable actors on the pressure plate. If the total weight is greater or equal to the pressure plate weight requirement the pressure plate activates
Possible ways to move the grabbed object?
1. Get the location of the pawn and an offset and set the position of the grabbed actor to that equation
2. Parent the grabbed actor to the pawn
How may you know what to grab?
1. Put a component on each grabbable actor - this component will also be responsible for determine weight and highlighting the actor
All grabbable actors within a room are apart of an array set on the pressure plate