I wanted my score and high score text objects to contain text other than solely the score value (in this case it was a simple “Score: ” and “High Score: “). This did lead to a couple issues throughout the debugging process where I realized I didn’t add the extra text when changing/resetting score values, so the extra text would be missing and just the number would be shown. For larger projects, it may be safer and more consistent to make a separate small method for setting a score and/or high score that will add that extra text every time when called (removes a copy/paste step of doing similar actions throughout the scoring script.) And again following a main point from the Board to Bits video, set your key names as string variables within the code so they are easier to consistently call throughout your program.
Category: Programming
Saving Data in Unity: PlayerPrefs
Saving Data in Unity: PlayerPrefs – Youtube Link
Youtube tutorial by Board to Bits Games going over the basics of PlayerPrefs in Unity. This shows limitations of PlayerPrefs as something that is mostly useful for storing smaller amounts of data for the player on their system. This also showed a good practice to follow when using key value pairs: set your key as a string variable so that you can call that key variable name every time you need it instead of hoping you type it in exactly correctly every time.
How to Make a High Score in Unity
How to make a HIGH SCORE in Unity by Brackeys
How to make a HIGH SCORE in Unity – Youtube Link
This youtube tutorial from Brackeys shows the bare bones way of getting a high score system started for a game in Unity. It uses the built in PlayerPrefs function to save data to the user’s system.
PlayerPrefs.SetInt and PlayerPrefs.GetInt were used. Playerprefs.SetInt lets you set a key value (which is basically a name for this value when you want to find it) and the actual value to set to this key at the time. Playerprefs.GetInt will return the value stored at the key value given to it, or if nothing is stored within that key location, it will return the default value, which is the second variable value you set when using PlayerPrefs.GetInt.
Altering UI Grid System for Unity 2017
Changing our project from Unity 2018 to 2017 caused a small issue with the UI grid system I created. It relied on a prefab of a UI image object, which 2017 does not play nicely with. They did not take on the positional data assigned to them on instantiation, they would simply keep the transform information of the prefab, so they would all be in the same location which does not create our nice grid.
To get around the need for a prefab, I simply created new gameObjects which then had image components added to them and attached the necessary script since our objects were relatively small and simple. This got around the issue of needing a preexisting object to instantiate in the first place.
These UI image prefabs also had an event trigger attached to them to perform the method to change their color and array value when clicked, so this also needed to be attached or emulated when creating these new objects. Instead of specifically trying to add a pointer click event trigger, I simply added an OnPointerDown method to the script already being attached to the newly created objects that would perform the array value changing method.
Links Referenced for Solution:
UI OnPointerDown Method for Unity
Create UI Elements in Unity
Additional Image Reading Feature for UI Grid Tool
Another feature was added to this tool to help the artists make wall assets for the game, but it also doubles as another option for therapists to create wall poses. The UI grid can intake an image file (a 2D sprite) and output a grid based on the alpha values of individual pixels from this input image. This initially always looked at every pixel, but to help the tool deal with higher resolution (or just larger) images, I also added a resolution factor that would just very simply look at “every x pixels” instead of each individual one. The resolution factor just gets multiplied into the loop looking for pixels.
For example: With resolution factor of 4, the tool will look at pixel numbers: 0 * 4 = 0, 1 * 4 = 4, 2 * 4 = 8, etc.
While this clearly isn’t an amazingly intelligent system, it is a simple way to generally get a roughly similar shape to initially higher resolution images without creating hundreds of thousands of objects.
Creating UI Grid to Build Wall of Objects
Our team wanted to created a tool that could generate walls made of blocks for our “Hole in the Wall” style game. As a health game, we also wanted to have an in game system that a therapist could use to create their own wall objects as well. To satisfy these requests I decided to create a simple UI grid made of images that would tie into a wall generator object in Unity.
Using Unity 2018, I was able to use UI Image prefab objects. The height and width of the wall can be determined in “number of objects”. This will also be reflected in the UI grid object. The user can then click grid elements to either turn them on or off, which will also correspond with a color (white or black). Then when the user clicks the “create wall” button, a wall will be created of 3d objects directly reflecting the UI grid. The wall will have objects where the grid elements are on, and it will just have nothing (a hole) where elements are off.
Experimenting with Unity: Player Movement – Rotation
Player controlled by rotation about a point
Vimeo – Video of Rotational Movement
I was experimenting with controlling a player agent solely through rotational forces. The first style I looked at was not a force in the physical sense as it just operates on moving the player at a constant rotation speed. This is dictated by the placement of a rotation pivot which the player can place to indirectly move the player agent.
To add an extra amount of control, the player can also press a key in order to reverse the direction of the rotation (switch between clockwise and counterclockwise). This combination of features led to some interesting movement patterns. One of the first things that jumps out is the fact that the movement being dictated by a constant rotation speed still leads to varying velocities by the player agent as this will vary drastically with the radius between the pivot point and the player object. Large pivot distances can lead to dramatic speeds, but will lead to the player covering a larger area.
Notes to remember:
I was having an issue where the rotation was not perfectly making a circle in the game view. It turns out the scripts were correct, but the camera needed to be set to orthographic so the camera was just viewing it at an angle. Remember to check both the editor view and game view closely to help determine camera-based issues.
Using cursor inputs in Unity is a bit awkward. It has been done plenty of times so the basic scripting is available on Unity’s main site, but the process of creating a plane, raycasting, and converting between screen and world space is a lot to keep track of. This might also be something to look into if mouse inputs are acting strange.
Procedural Generation – Far Cry 5 GDC Content Generation
Procedural Generation – GDC 2018 Talk – Procedural World Generation of ‘Far Cry 5’
By: Etienne Carrier
GDC 2018 – Procedural World Generation of ‘Far Cry 5’ – GDC Vault Link
GDC talk where Etienne details a large scale tool they created using procedural generation techniques to help build the world of Far Cry 5. It covers both the user end (world editors/designers) and the behind the scenes processes that make everything possible. They use Dunia and Houdini together to create these tools.
Learning to Create Tactics Movement in Unity
Links to Tutorials from Game Programming Academy
Link to Game Programming Academy Tutorials for Tactics Movement
Link to Youtube of 1st Tutorial
These references break down the basics of tactics movement and how to setup a basic system using it in a game through Unity.
Creating a Basic High Score System in Unity
October 13th, 2018
How to Make a High Score in Unity
How to make a HIGH SCORE in Unity – Brackeys
How to make a HIGH SCORE in Unity – Youtube Link
This youtube tutorial from Brackeys shows the bare bones way of getting a high score system started for a game in Unity. It uses the built in PlayerPrefs function to save data to the user’s system.
PlayerPrefs.SetInt and PlayerPrefs.GetInt were used. Playerprefs.SetInt lets you set a key value (which is basically a name for this value when you want to find it) and the actual value to set to this key at the time. Playerprefs.GetInt will return the value stored at the key value given to it, or if nothing is stored within that key location, it will return the default value, which is the second variable value you set when using PlayerPrefs.GetInt.
Saving Data in Unity: PlayerPrefs
Saving Data in Unity: PlayerPrefs – Youtube Link
Youtube tutorial by Board to Bits Games going over the basics of PlayerPrefs in Unity. This shows limitations of PlayerPrefs as something that is mostly useful for storing smaller amounts of data for the player on their system. This also showed a good practice to follow when using key value pairs: set your key as a string variable so that you can call that key variable name every time you need it instead of hoping you type it in exactly correctly every time.
Lessons Learned:
I wanted my score and high score text objects to contain text other than solely the score value (in this case it was a simple “Score: ” and “High Score: “). This did lead to a couple issues throughout the debugging process where I realized I didn’t add the extra text when changing/resetting score values, so the extra text would be missing and just the number would be shown. For larger projects, it may be safer and more consistent to make a separate small method for setting a score and/or high score that will add that extra text every time when called (removes a copy/paste step of doing similar actions throughout the scoring script.) And again following a main point from the Board to Bits video, set your key names as string variables within the code so they are easier to consistently call throughout your program.