Post

Visualizzazione dei post con l'etichetta gamedev

Working buttons

Immagine
In this post we already bound functions to the pressing of either the "Deploy mine" or"Repair" buttons. Now it's time to make them really work! First, the easier one: Repair button. In this case it's just a matter of completing the Repair() function; I want all these actions to happen only when we are in the player's turn, which means being in gameState == 0. If we're not in it, simply return. We also have a boolean variable called repairAvailable , that updates itself based on how many resources we collected; if it's false , let's return as well. In case none of the above happens, we can actually repair our ship: this means adding 1 life to the player ship, and removing 2 resources from our collection. Please note that calling the AddLives() and RemoveResources() methods, will automatically take care of updating the UI and the repairAvailable variable. (In this case the UI will be redrawn twice, but it's not a problem). Here...

3D printing the starship miniature

Immagine
In the previous post  I modified the starship model used in-game to make it's printable, adding details and making sure it's manifold . Let's export it in a print-friendly format, like .STL : Now it's time to give it a pass with a dedicated software to check its integrity. Since my O.S. is Windows 10, i'm going to use the built-in application 3D Build ; it's very simple but works perfectly for checking and repairing 3D models. There are many alternatives online, like Netfabb by Autodesk (you can download the free trial: for the first 30 days you'll have access to all the functionalities of the software, and after the trial expires you still have the basic features working, and they're enough to preview and fix your 3d models). Importing the model Automatic repair Now, with my Geeetech Prusa I3 MK2 3D printer I'm going to use the dedicated software called Repetier; this will use an engine called Slic3r to create a series o...

Cloaking device

Immagine
The next problem I want to address is hiding the enemy ships when they're on undiscovered tiles, and obviously showing them as soon as they enter a discovered one. This can be easily done with the Actor's SetActorHiddenInGame() method, but I want to try and make the effect a little nicer, by playing an animation from totally transparent to totally opaque while the ship is moving. But first things first, let's use visibility to make it visible as soon as it starts to move from an undiscovered tile to a discovered one: Since all enemies start from outside the grid, their initial visibility will be set to "hidden" by default: Remember that the method sets the Actor to Hidden, so passing a true parameter means we want it to be invisible, and passing false will show it. Then I created a new int variable in enemyClass.h, and I called it changeTransparency; it can take 3 values: 0: the ship doesn't need to change its transparency. ...

User Interface - Updating when triggered

Immagine
Here we are, we have almost finished our work on the User Interface. In the previous post  we created the building blocks to update the interface when a DrawUI event is triggered from code. Now let's see how to actually draw the changes on screen. Let's say we have 2 health points left out of 3. Then I want to draw 2 green ships icons, and 1 grey ship, like this: I have to create 2 FOR loops: the first one from 1 to lives  for the green ships; the second one from life + 1  to maxLives  for the grey ships. (We created these variables here , in case you don't remember). It could be easily done by code, but since I'm working on the HUD inside its blueprint, I will try to write this in the graph editor. We already added 2 WrapBoxes to the HUD, one for health points and one for resources; the first step is to remove any object inside each box, so we can start from empty containers. Unreal gives us the useful method Clear Children, that we're go...

User interface - Adding functionalities

Immagine
In the previous post we created the layout for our user interface. Before going on with the work on it, I want to add some useful stuff to C++ code. I decided to store all informations about the player status (health points, resources, etc.) in the PlayerController class, becuse it seems the most logic place for them. So I'm adding a bunch of new variables: lives:  the number of actual health points left; maxLives:  the maximum number of available health points (it's 3 for now); resources:  the number of collected resources; maxResources:  the maximum number of collectible resources (let's say it's our cargo space, and I'm setting it to 5 for now). All these variables are created with the UPROPERTY macro, so that they're visible from the Blueprints, and can be used to modify the User Interface widget. I'm also going to create some new UFUNCTION methods that will handle the events coming from the User Interface buttons: selectOpti...