Minigame Monday: Getting It Back

 Getting it back:

  • The concept:

I returned to Unreal for this one; I decided I wanted to use the engine before I decided on the concept, but I soon came up with the idea of doing a volleyball game. This gave me the chance to experiment and practice a bit more with physics in unreal, and manipulating objects as desired. Unlike previous games in Unreal, I didn't tie myself to using C++ or blueprints, and instead decided to just use what made the most sense to me at the time. Suprisingly, I ended up using blueprints a lot more than I expected, I think because some of the logic behind them was starting to click with me, and I understood more that I could consider blueprint hierachy the same way as hierachy in C++.

  • The challenge:

 The first thing I looked at for this game was the physics, and making the ball feel the right amount of floaty so that it was possible to hit back, but also allow it to fly at a decent speed so that the player could add a decent amount of force to it. I played with a few factors to get the effect I wanted; I added a physics material to the ball, to allow it to bounce strongly off objects, and changed its mass and drag values to give the ball a floaty effect. This required a bit of fine tuning, because ligher mass values would also make the ball fly further when hit.

Next, I created the enemy. To my suprise, I ended up using blueprints for this. A couple of things clicked for me when doing this, mostly using functions in blueprints and using references in blueprints, and I found that I didn't actually need to use C++ for this. Blueprint functions, in particular, allowed me to neaten up my work considerably and make it far more managable, which meant I was happier to create functionality that otherwise I would have wanted to define in C++ to avoid the mess it would have needed.

The function for detecting if the ball is close
 

As a result, the overaching AI for the opponent is very simple; if the ball is close, hit it, otherwise move towards it. Within the 'Move To Ball' function is a sub function defining the bounds where the AI can move, so the opponent never leaves their side of the court.

The opponent AI, making use of functions
 

 I did, however, use C++ for keeping score. I wrote a class that stored the details of the score; honestly, this class could have used blueprints too, however I'm glad I used C++ as it gave me some practice for interfacing between C++ and blueprints. The other place I used C++ was for the UI; I created a class deriving from UUserWidget, and then added a function to produce the text I wanted. I then built a UI using Unreal's widget designer, and then reparented the UI I had built to my new class. This allowed me to call my function, and with widget binding directly change the UI element I wanted.

  • The result:

Gameplay
 

While this game wasn't the most complicated or detailed, I think it turned out pretty well, as evidenced by the time I spent playing it while testing. Hitting the ball takes some getting used to, but once you have you can try a number of different tactics to out manuever the AI. You can try the game for yourself at https://reddragonmakesgames.itch.io/getting-it-back.
 





Comments

Popular posts from this blog

Armageddump (Boss Rush Jam 2023)

Imperfect Control: Gameplay

Hair of the Wolf (GameOff 2022)