Next Broadcast

Learning how to program basic CRPG mechanics in UE5

Bodyburger GameDev DK30 Fall 2022 2 1

Description

I’m taking at least November off from work, using that time to study gameplay programming in UE5, and making my first small demo in it. I intend to learn ways to create some base mechanics like we see in CRPGs, starting with character selection and movement with mouse. I’ll also include my last few lectures from a UE5 online course that I’ve been working on for a couple of months now. I’m breaking these into smaller steps, since keeping parts of this project achievable and low stress is as important as a goal as the mechanics created in the demo.

Recent Updates

Bodyburger 2 years ago

Oh, and here’s my Github project link! https://github.com/Bodyburger/RPGMechanics_Demo_Repo

Bodyburger 2 years ago

Selected And Moved Characters. What’s Next?

Tuesday 15/11/ To quote Week 4 Goal’s heading and some poet-guy Alfred Lord Tennyson: " ‘Tis better to have loved and lost than never to have loved at all ". (Thanks Brainyquotes)

At the beginning of this project I hoped that the C++ side of Unreal Engine 5 was documented well enough so that I could utilize movement functions with ease in code. Turns out “SimpleMoveToLocation()” function implementation wasn’t that simple, as I needed to learn small, but critical things on the way.

Today one of those small things were dependency modules and their list in Build.cs, which I had already forgotten to have existed. I spent the better half of this week figuring out why the “SimpleMove…()” didn’t compile/build. I needed to add “AIModule” manually to the list, even though the game engine works fine if I used that function in Blueprints like in my previous update. Can you imagine.

So the SimpleMoveToLocation() did not work, although I got it into the build with no errors. That function should move the character to a location if the player only clicked and held the mouse button down less than 0.3 seconds. Otherwise it’s moving the character via AddMovementInput() on every frame, when the player is holding down the button.

I did what I aimed to do in this project, and for that, I am truly happy. The course that I finished during first week gave me a wide introduction to UE5 features and C++ game programming. The notes and information I’ve gathered in game dev studies are neatly packed in Obsidian, and will be made use of time and time again in future projects.

Speaking of future projects… I will have a planning and celebration day tomorrow, so I’m taking things a bit easier. I’ll go to a cafe to draw and write things down and talk to people. It’s possible that I’d come back to this one, clean it up and continue with some interesting mechanics. Other possibilities are:

  • Complete Unity RPG course (Already have it)
    • Follow Unity RPG course and translate it to UE5
  • Find and complete C++ math course etc.
  • Find and complete C++ RPG course
  • Join someone else’s existing project as a programmer

Obviously I want to and I need to look for a gameplay programmer’s job. Preferably in some studio that uses Unreal Engine or C++. (Take me Larian. I’m all yours.)

DK30 was a good experience for me in general. I enjoyed following other people’s updates as well as keeping my own work and progress pretty much stress free. Thanks to everyone who participated and updated their projects !

Bodyburger 2 years ago

Moving things in C++

Friday 12/11/

I’ve been working on OrderMove() function for about a week now. I did a Blueprint tutorial which basically told me how to create exactly what I was after.

So the rest of the last workdays went into reading UE documents and realizing, that it’s often easier to just open functions in Visual Studio and read what they do.

Today I created simple movement in C++, but there’s still some things to add before I call it done.

Bodyburger 2 years ago

These holes have rabbits in them …

Saturday 05/11/

I found a bunch of guiding youtube videos on how to create cursor based character selection, as well as unit and character movement. Again sadly, these were tutorials that used blueprints, so most of my time goes into translating them to C++, which isn’t covered very well in the documents. I know now that I could quite easily create my desired basic CRPG movement system and controls via Blueprints, so if my time starts to run out, I’ll do that instead and then continue with C++ after dk30.

Previously I’ve been refactoring again, because I have a better grasp on the architecture needed. The player simply uses AController class that deals with mouse inputs and other interactivity, and that class posesses/moves APawn class, which has a camera component and deals with movement inputs. The units/characters are stored into an array “on click”, like I explained in my last update, and so now I’m figuring out and translating the “character move commands”.

Current and ongoing problem is: I don’t know what functions are available for moving ACharacters and APawns through C++. Sure, I’ve found some “AddMovement…” functions etc., but I feel that each of them is a rabbit hole that has even more functions inside, and it’s time consuming getting through all of the options. At the same time it’s very rewarding, since I like knowing… Everything. :)

Current progress:

  • [/] Learn how to move a character with mouse.
  • [/] Learn how to select and posess multiple characters.
  • [/] Learn how to move multiple characters.
  • [ ] Learn how to keep camera position between selected characters. Not necessary.

See ya ! 8)

Bodyburger 2 years ago

I Recognize My Character, Now…

Thursday 03/11/

Update on the last five days: I figured out how to make cursor visible in code, how and where to use GetHitResultUnderCursor(), and refactored old bits of code. Working with HitResult and specifically that function above was a bit difficult. I tried to use it in ACharacter class first, and then realized that I should have this feature within AController instead. Before too long, I had things refactored and working properly.

So today and yesterday I worked on HitResult. It needed to recognize if the hit was ACharacter or not and print the results in console whatever the case was. I also made a ‘SelectCharacterWithMouse()’ function that does what was mentioned above, adds the ACharacter that was hit to ACharacter array, empties the array if the player clicked on something that wasn’t ACharacter, and finally draws a debug sphere at the hit impactpoint. This means that the base for my selection system is complete !

Current progress from week 2 to 3:

[x] Learn how to make cursor visible.
[x] Learn how to select characters with mouse using Line Trace By Channel etc. (also deselect).
[ ] Learn how to move selected characters.

I am already thrilled with how much I’ve learned, though the last part in my plan, “creating movement for selected characters”, will presumably be the most difficult task so far and will require a better understanding of pawns, actors, characters and controllers.

Vi ses, see ya next time, nähää !

Bodyburger 2 years ago

Reassuring progress

Friday 28/10

  • [x] Fix the camera / spring arm bug that was created last week.
  • I simply commented out previous functions “SetCameraShoulderLocation()” and “SetCameraOriginLocation”, since they caused camera position bugs. They didn’t work with the spring arm component without modifications, and weren’t important enough to keep.
  • “ToeView” Was fixed by raising the Spring Arm Component in BP_CameraCharacter.
  • [x] Modify existing code to get a top-down view of the world / level.
  • Changed some numbers and rotated the Spring Arm in character Blueprint.
  • [x] Research and try to have a camera as is, but without a character being spawned with it and posessed automatically.
  • I tried to figure out if I should:
    • [ ] Delete the Mesh Component in ACameraCharacter.
    • [ ] Try to create a new CameraClass without inheriting ACharacter. The CharacterMovementComponent is specific to Characters and cannot be implemented by any other class. It’s automatically added when creating Blueprints based on the Character class.
    • [x] Decided to simply clear the Skeletal Mesh slot. Easy peasy.

During Week 2:

  • [ ] Learn how to make cursor visible.
  • [ ] Learn how to select characters with mouse using Line Trace By Channel etc. (also deselect).
  • [ ] Learn how to move and keep camera on top of selected character.

Next Monday is the last workday before November’s full-time studies. I’m glad I have more time to figure out how to make the characters move with mouse commands, since I haven’t done in it Unreal Engine before.

Bodyburger 2 years ago

Creating a Camera with a Spring Arm Component

Friday 28/10/ - Updating the first week’s day 7. Better late than never.

  • [x] Check how UE5’s TopDown-template deals with the camera.
  • [x] Follow UE5(C++) documentation Working with Camera Components | UE5 Docs
  • When entering PIE (Play In Editor), I can only seem to posess the new CameraCharacter only if I have placed the BP_CameraCharacter into the level… If not, BP_ThirdPersonCharacter is spawned and used for some reason. I’ve set game mode and default pawn correctly, so I’m at a loss here. No biggie - I continued to the next bit.
  • [x] Follow UE5(C++) documentation Using Spring Arm Components | UE5 Docs.

I learned that Controller is a ““standard”” name convention in APawn ! It doesn’t cause squiggly lines when using it without declaration because the class knows it already ! Small victories …

  • I followed through both of these documentations and was left with LookUp-camera movement and camera position being somehow screwed, so I need to refactor some of the code.

Again, problems with embedding… I used Imgur’s “Embed post” feature and it worked.

‘Insert image’ didn’t work. Buggy Camera

Bodyburger 3 years ago

Planning and Researching

Monday 24/10/ I was sick today and yesterday, but at least it isn’t COVID, so I managed to do some planning.

I found videos and lectures about character movement with mouse and some camera stuff, but they mostly just show how you can use Blueprints to create them. Since I’d like to get better at C++, I might try converting the Blueprint info into code.

If I’m getting stuck with simpler things like setupping an actor with components in C++ etc., I’ve written notes in Obsidian during the UE5 course that I can quickly search through for help. Oh, and I need to get used to finding answers in the documentation/online faster.

I feel like I should determine restrictions on what I can use and can’t. If I use UE5’s features as much as possible, I could create a portfolio piece for this engine specifically. This sounds good in a way, but it doesn’t push me too much towards a game dev job where C++ and a “custom engine” is used. I don’t know what would be most beneficial and it bothers me. It’s such a tease to have all the tools UE introduces, but not utilizing them.

Until next time.

Bodyburger 3 years ago

Completed the Course ! Free Recap

Friday 21/10/ recap: Due to compiling times and weird Visual Studio Code errors, these lectures took a duck-ton more time than expected. I worked from 12:20’ish to 23:30 on the courses, of course taking some breaks for stretching, cooking food and eating. So 10 to 11 hours compared to estimated 4 to 5 hours. What did I learn? A lot of animation implementation, behavior scripting etc., and also that I should have my estimations quadrupled rather than doubled. Just to be sure.


It’s Friday 14:40, and I’ve been working on the lectures for about 2 hours now. The compiling times and waiting in Visual Studio Code for random squiggly lines to disappear etc. consumes so much time ! So far I’ve completed 2 lectures out of 11 today:

  • Calculating The Win Condition (12 min)
  • Refactoring PullTrigger (8min)

-Time skip-

It’s 23:39 on Friday. I just completed the course and got my certificate. Phew I always write down in Obsidian (a knowledge base program) what I go through and learn in courses. I could just copy-paste notes here, but I don’t think that’s fun for anyone to read except me, so I’ll give you a short video of what I made in that course instead.

Well. I can’t get embedding to work, so here’s a youtube link: 3rd Person Shooter - UE5/C++ course final project

Bodyburger 3 years ago

We meet again, Mr. Loop

To celebrate the beginning of this project, I went and bought a cinnamon bun. I didn’t drink any coffee or hot cocoa with it, but it was good. Off to a great start !

Following the first lecture ‘Iterating Over Actors’, I learned about ‘TActorRange<>()’ that iterates through all actors in a given level. We used it to look for every ‘AController’ with a for-loop and determined who the winner is when the game ends.

If the Controller is a PlayerController AND the winning actor is Player, OR, if the controller isn’t a PlayerController AND the winning actor isn’t Player: We call “Controller->GameHasEnded(Controller->GetPawn(), bIsWinner)”. Here the first parameter determines the camera’s focus, so in our case it focuses on whoever is the winner. The second parameter states if the Controller was the winner.

~~Looking for equal booleans; BoolExample ~~ I made a neat table but it didn’t work. :(

| ----------- | true | false | | true | ✓ | X | | false | X | ✓ |

I created two if-statements and an ‘else’ at the end, but the lecturer had a lot more efficient and cleaner way of writing this bit of code, and so I learned …!

void AKillEmAllGameMode::EndGame(bool bIsPlayerWinner)
{
    for (AController* Controller : TActorRange<AController>(GetWorld()))
    {
        bool bIsWinner = Controller->IsPlayerController() == bIsPlayerWinner;
        Controller->GameHasEnded(Controller->GetPawn(), bIsWinner);
    }
}

So… I completed the lecture, but it took about an hour compared to my former approximation of ~2x length of the lecture (10min x 2 = 20min). Admittedly, my brains couldn’t focus much after a day of work and my thoughts bounced around wildly. My sleep and mental health have not been great this year, but I trust myself to know my limits quite well at this point. I’ve felt enthusiastic about dk30 and next Friday as I continue this, I will have a fresh mindset. I’m going to stick with my plan for now and assume that the rest of the course will be completed on Friday. (Writing this update took about 1h 30min and I should be asleep already, whoops)

Estimated Timeframe

Oct 19th - Nov 17th

Week 1 Goal

“Season of mists and mellow fruitfulness”

Finish UE5 online course. This includes 113 minutes worth of lectures divided into 11 lectures. Following the lectures, programming and compiling code takes at least 1.5x if not over 2x a video’s base length, so by adding some time on top of that (because rrrors and brain farts) I assume I can deal with these in approximately 4-5 hours. This should be very achievable withing one week and I’m guessing I’ll have spare time to plan next week’s steps as well. This week my working hours on dk30 will be spent in the evening on Wednesday 19th, on Friday (~8h during the day), possibly on Satuday if I got some insurmountable problems with the lectures, and pretty much on any weekday evening up until Week 2 except.

  1. Iterating Over Actors (10min)
  2. Calculating The Win Condition (12min)
  3. Refactoring PullTrigger (8min)
  4. Weapon Sound Effects (7min)
  5. Randomized Sound Cues (9min)
  6. Sound Spatialization (7min)
  7. Crosshairs and HUDs (8min)
  8. Health Bars (8min)
  9. Aim Offsets (12min)
  10. Animation State Machines (10min)
  11. Complex State Machines (13min)
  12. Wrap-Up And Challenges (9min)

Week 2 Goal

“To be or not to be: that is the question”

Original plan: Research possible ways of programming in C++ a character selection system and movement with mouse.

  • Start a new UE5 project.
  • Take the first step into the unknown.
  • Update how I’m doing.

New plan, now that I am twice as wise:

  • [x] Fix the camera / spring arm bug that was created last week.
  • [x] Modify existing code to get a top-down view of the world / level.
  • [x] Research and try to have a camera as is, but without a character being spawned with it and posessed automatically.
  • [ ] Learn how to make cursor visible.
  • [ ] Learn how to select characters with mouse using Line Trace By Channel etc.
  • [ ] Learn how to move and keep camera smoothly on top of selected character.

Week 3 Goal

“Two roads diverged in a wood, and I – I took the road less traveled by”

Original plan:

  • Take the second step into the unknown.
  • Update how I’m doing.

New plan:

  • [ ] Learn how to move a character with mouse.
  • [ ] Learn how to select and posess multiple characters.
  • [ ] Learn how to move multiple characters.
  • [ ] Learn how to keep camera position between selected characters Not needed.

Week 4 Goal

“‘Tis better to have loved and lost than never to have loved at all”

Original plan:

  • Take the third step into the unknown.
  • Celebrate what I managed to get done !
  • Think about how to proceed.
  • Update how I did.

New plan:

  • [ ] Fix issues, fine-tune.
  • [ ] Celebrate what I managed to get done !
  • [ ] Think about how to proceed. November is open for full-time studies.

Tags

  • Unreal Engine
  • UE5
  • UE
  • Game
  • Programming
  • First
  • Demo
  • C++