Tactics Movement Tutorial (Cont.) – Turn Manager

January 3rd, 2019

Turn Manager – Tactics

Turn Management

Youtube – Unity Tutorial – Tactics Movement – Part 5

By: Game Programming Academy

This part of the tactics game tutorials focused on creating the turn manager. An NPC character was created to represent another team. Even though there are only two units, the tutorial design deals with entire teams. The turnManager used static variables and methods because it should be very accessible and will act as a sort of global since there should only ever be one.

TERMINOLOGY

Subscriber Pattern: the tutorial mentions using this method to add units to the turn manager queue. This was tied to the idea that when a unit comes “online”, it should be able to add itself to the proper list in dictionary.

Dictionary: more uses of this in turnManager system, so I still need to look into this to see how they work.

NOTES

Will need to add method to remove unit from queue when it is defeated, which will then also lead into another method that will be needed for dealing with what happens when an entire team is defeated.

There was a method named “EndTurn” in the TurnManager script and the TacticsMove script. I am not sure if this is a bad practice or something that is generally done without consequence.

PROBLEMS

My units could move through each other or even on to the same space. Going back to tutorial video “Tactics Movement – Part 2” I saw there was an adjacencyList.Clear(); command I was missing in my Tile Reset method. Adding this back in fixed the issue. I wasn’t sure if this was removed later in the tutorial by the tutorial itself for bug testing when player movement was buggy. After checking video “Tactics Movement – Part 4” in the debugging segment, this does not appear to be the case, so it does seem that I just missed that line of code the first time.

High Score and Saving Data in Unity: 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.

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.