Starting Out by Planning


Introduction

This project will be my submission to the Gamedev.tv community jam. This jam last for whole month of May 2020, but since I've been participating in another jam this month (SimJam) I've started on the 18th. This should still leave me enough time to finish something fun, but I will have to keep the scope of the project down a bit. I want to write a few devlog posts as I go through this process, mostly for myself, in order to improve on my planning which I think has been a bit lackluster in previous jams. I'll be using Unity & C# to make this game as I have done for my other projects.

Pitch

So to start, the game idea itself is a fast-paced 2D shooter, where you are a time-cop inside a clockface fending off time-leeches and other horrors that try to disrupt the flow of time. The game play should involve a lot of fast jumping and shooting in close quarters as enemies spawn, which will be dynamic as the flow of time changes based on the enemies' actions. Hopefully this should provide some fun interactions and replayability as the player fights to survive as long as possible, with the whirring clock hands and strange enemies providing an ever changing environment.

Starting out

Over the last couple of days I've played around in Unity with how to control the flow of time. One way to do so is to change the Time.timeScale, e.g. the real-time between frames. This has problems associated with it, namely that you have to reduce the physics delta-time to still accurately capture collisions, and that it is completely global. I would like to have some enemies that are not effected by the change in time flow, and I am still not decided on how projectiles should respond to the time flow. So for now I have another solution: a singleton class TimeController that keeps track of a float (timeScale) that I use to multiply forces and velocities throughout the game. This isn't a perfect solution, since it requires me to modify the gravity on all the rigidbodies whenever the timescale changes as well as their current velocities. I've worked around this by creating a custom event for when the timeScale changes, that each of the entities that responds to time flow can listen for and change their velocities accordingly. This solution I think could be improved on, but for the scale of this project I think it is ok. For a larger project I think you might want to create your own RigidBody variant that you use for these time-sensitive entities, but here that would be a bit overkill.

Planning

With the background physics sorted out, I went ahead and made a more detailed plan on how I was going to program the entities in the game, namely the player, enemies, and projectiles.

The enemies are the most complex so I'll start there. I'm going to be using a generic component class EnemyController that will handle the movement, actions, and animations of the enemy. However those movements and actions will be quite different between enemies, so I've decided to have the EnemyController just call each of the enemies custom movements/actions through their own custom components. These custom components will all implement the same interface (IEnemyAI), so that the EnemyController can just contain a reference to a generic IEnemyAI implementation. I think this will allow me to minimize the repeated code between the different enemy types, which on top of creating some nested prefab should make it very easy to change all of the enemies as I work on them, while keeping the different enemy types feeling unique.

I'll be handling the damage and HP of the enemies and player through a separate component that I can just attach to all of them. In this case the behaviour of the players and enemies when taking damage is the same, so it doesn't make sense to create an IDamageable interface or something. The actual dealing of damage will be done by the bullets collision trigger, that will check for this HP component, and if present will deal damage.

This leads me on to the collisions. The tricky part here is that not all things should collide with all others, for instance the player should not collide with their own bullets and some enemies will not collide with the environment. For now the best way I know to handle this is through the collision matrix that unity provides for game objects on different layers. This seems a little risky as it relies on me placing all of the objects on the right layers, but hopefully with almost everything being spawned from a prefab this shouldn't be hard to keep track of.

Moving Forward

So that's it for my first attempt at a devlog! As I said before this is mostly for me to look back on to help improve, and it has helped force me to make a more concrete plan for my code, which should be very helpful. Since the deadline is only in a few weeks I'm not expecting to make many posts, but I will post any problems I come across and changes to my plans as they happen.

Leave a comment

Log in with itch.io to leave a comment.