Course: Building a Block Based Game

In this course, you’ll create a sandbox-style game in Unreal Engine in which the player can build their own world with blocks of their own design. Along the way, you’ll learn about object-oriented programming using Inheritance, as well as many other important programming concepts.

After finishing this course, you’ll have a complete game framework and a platform on which to customize and build a game you design.

https://dev.epicgames.com/community/learning/courses/qZr/unreal-engine-building-a-block-based-game

5 Likes

The first video in the tutorial shows that the SK_BlockCharacter has a Block attached to its right thumb. In the project I downloaded from the Epic Launcher, the SK_BlockCharacter does not have that Block…

1 Like

Greetings all,

I’m the instructor from the course. As @Whzak noticed above, the Character does not have the block attached - that happens in a later lesson.

The SK_BlockCharacter in the Unreal Learning Kit is also missing the socket that is demonstrated in the video.

There are two fixes for that:

Fix 1. Ignore the BlockSocket and when it comes time to attach the PreviewBlock component, search for “thumb_03_r” in the Parent Socket rather than the (missing) BlockSocket.
image

…or…

Fix 2. Add the BlockSocket to the SK_BlockCharacter by editing the SK_BlockCharacter, go to the Skeleton Tree tab, locate thumb_03_r, right-click, select “Add Socket” from the menu, name the socket “BlockSocket”, save, then close the SK_BlockCharacter.
image

Also, please note: The method of adding blocks using a blueprint and static mesh for each block can be very memory intensive if you add thousands of blocks. There are better ways to achieve a “block style game”, such as using instanced static meshes (ISMs). The educational goal of this course was to introduce an object-oriented hierarchy and give people a way to create custom blocks of their own design without having an overly complicated system for dealing with the visual aspect of the blocks.

I sincerely hope you enjoy the course and find it valuable! Please let me know if you have any questions.

6 Likes

Thank you for the tutorial.
I have a question about the SetTimerByEvent logic before either placing or removing the block.
What is the logic for this? Can we not just connect the logics after the custom events directly to the input actions?

The method demonstrated in the tutorial repeats the action while the RemoveBlock action is occurring (i.e. the mouse button is held down) by setting a timer that loops every .2 seconds. The timer repeatedly calls the RemoveBlockFromWorld custom event. When the RemoveBlock action key is released, the timer is cleared. The idea is that the action repeats while the mouse button is held down.

EDIT: The information below is not correct - the code below will result in blocks being removed even when the mouse button is released.

You are correct that this could also be accomplished using a delay at the end of the nodes and looping back around to the beginning. The issue I see is the logic using this method is a little more convoluted; you have to account for the False conditions in the Branch nodes to keep looping if the cursor isn’t on a block, or a breakable block. Here is how it would look:

In the end, it boils down to a design decision. Either way works, I just found the method in the tutorial to be easier to follow (in my opinion).

Thank you for the feedback!

1 Like

@kevin0228ca - please see the additional comment I added above - the code I posted isn’t correct.

The method used in the tutorial works as desired since the action is stopped (the timer is cleared) when the mouse button is released.

Thinking out loud, the modified code below would let you use the method in the post above, but I still like the original implementation more.

You could try this though:

This is such a wonderful initiative Mathew.
I hope you continue to make more educational content.

cheers,
Behram

thank you, very clear explanation!

1 Like

Nice valuable course, very useful to newbies like me, I have learned a lot from it, thanks you.

1 Like

There is one little issue in the Placing Blocks tutorial which can be improved.
That is, when the character turns to the clicked direction, it may turns from the opposite side with a larger rotation angle rather than from the side with a smaller one.
This is happened when one of the rotation yaw returned by the “Get Actor Rotation” and “Find Lookat Roation” function is less than 0, and the absolute value of difference of the two rotation yaw is larger than 180 degrees.
So it’s better to increase the rotation yaw by 360 degrees if the CurrentRotation or TargetRotation variable is minus in this case.
Below is the solution I made for your reference.

1 Like

Hi @uniwang!

Thanks for your feedback, explanation, and code!

This may have not been in the video (I’ll have to go back and look), but I believe using the “Shortest Path” setting on the Lerp (Rotator) node in the timeline accomplishes this as well. Here is the code I have in my project:

EDIT: Just looked at the video, the “Shortest Path” check box is NOT checked in the RotateTimeline - it should be. As you noticed, it still works, but the character might rotate the long way around in certain circumstances. Thank you again for posting your solution!

1 Like

The “Shortest” option works very well, thanks for your timely reply and help :+1:

1 Like

Thanks for the lesson! This was my 1st touch with the software and I feel like this was just the kick i needed.

1 Like

You’re welcome! That’s great to hear that you got a boost from the course. Enjoy the journey!

Why does the game look like this when I try to swith to frist person view with the “set hidden in game” function in the event graph?

this is what I do in the event graph for inputaction:

But if I set the “hidden in game” field directly in the details panel of the mesh component, I can get the desired result looks like this.
image

@uniwang - is the FirstPersonView Action Mapping bound to F1 by chance?

If so, bind it to “F”. F1 will toggle that view that you’re seeing.

If that isn’t it, I’m stumped!

Yes, I bound F1 key to the inputaction, that is the reason.
Thank you so much :+1:

Another strange problem, when I press the WASD keys, the charactor does not move straight toward that direction, but moves a little to the left side every second.
And after I switch to the first person view, all the WASD keys will make the movement toward left back side to the camera direction.

input action and event graph:



charactor moves ahead with a little to the left very second in the third person view:
2022-10-07 15-14-38.mkv (5.0 MB)

@uniwang - a couple of possible solutions come to mind:

  1. If you have a game controller plugged in, unplug it and try again.

  2. Make sure the SetPreviewBlock function in the BP_BlockPlayer is removing the collision for the PreviewBlock:

Let me know if that helps.

One other possibility is the mouse is moving the crosshair and the character is turning accordingly.

Yes, it is the collison of the preview block causes the problem.
I just disable the whole preview block child actor collision, after that the character can walk straightly, and WASD keys also work correctlly in the first person view.
Thanks a lot for you help!