Meningitis
- Heather Roys
- Dec 10, 2024
- 2 min read
Updated: Feb 1

I became obsessed with adding villains, aka other bacteria, to the game. I thought of them as CAPOs or underbosses to the big boss I planned for the end of the game. The next bacteria I focused on was Meningitis. But Meningitis was tricky—it can kill you in 20 minutes. Luckily, I was able to ask real microbiologists, Bob and Tori, how binary fission works in Meningitis. They simplified it down to a "birthday cake party" level for me, which made it easier to understand and replicate in code!
Basically, I set everything on timers. When something reached the end of its lifecycle, it would activate its duplicate or "twin" that it carried with it. Each Meningitis bacterium on the screen carried a hidden twin. When the timer hit zero, the twin would spawn, doubling the number of Meningitis bacteria on the screen. It was my way of simulating self-replication!
"The following is the code for the Meningitis movement system. If you're not a game dev, you might want to skip this part unless you enjoy deciphering lines of code more confusing than your aunt’s holiday fruitcake recipe. Proceed at your own risk of existential dread (or sudden urges to become a game dev)."
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LeftMeningitis : MonoBehaviour
{
public float moveSpeed;
Rigidbody2D rb;
public Vector3 movement, movement2, movement3;
public Transform movePoint;
public float freq, amp;
public Transform[] meningitisArray;
public int spawnPoint;
public GameObject rightMengi;
public float CountDownTime;
private float CountDownCounter;
public float waitTime, waitTime2, splitTime;
private float waitTimeCounter, waitTimeCounter2, splitTimeCounter;
public bool canSplit, moving;
public GameObject newTransform;
public GameObject transformForSpawn;
public enum gamestate { firstSplit, spawning2ndMengi, fullMengiMovement, stopAndSetSplitSpawnPoints, movingToSplitSpawnPoints };
public gamestate currentState;
void Start()
{
rb = GetComponent<Rigidbody2D>();
splitTimeCounter = splitTime;
}
void Update()
{
if (canSplit)
{
if (splitTimeCounter > 0)
{
splitTimeCounter -= Time.deltaTime;
rb.isKinematic = false;
movePoint.parent = null;
movement = movePoint.position - transform.position;
rb.velocity = movement * moveSpeed;
if (Vector2.Distance(transform.position, movePoint.position) < .2f && splitTimeCounter <= 0)
{
movement = Vector3.zero;
CountDownCounter = CountDownTime;
}
}
if (CountDownTime > 0)
{
CountDownTime -= Time.deltaTime;
if (CountDownTime <= 0)

{
rightMengi.SetActive(true);
waitTimeCounter = waitTime;
}
}
else
{
if (waitTimeCounter > 0)
{
waitTimeCounter -= Time.deltaTime;
if (waitTimeCounter <= 0)
{
spawnPoint = Random.Range(0, meningitisArray.Length);
transform.SetParent(null);
movement2 = meningitisArray[spawnPoint].position - transform.position;
waitTimeCounter2 = waitTime2;
moving = true;
}
}
else
{
if (moving)
{
rb.velocity = movement2.normalized * moveSpeed;
if (Vector2.Distance(transform.position, meningitisArray[spawnPoint].position) < 0.2f)
{
movement2 = Vector3.zero;
if (waitTimeCounter2 > 0)
{
waitTimeCounter2 -= Time.deltaTime;
if (waitTimeCounter2 <= 0)
{
rightMengi.transform.SetParent(null);
movement3 = GameManager.instance.placeToMoveTo.transform.position - transform.position;
moving = false;
}
}
}
}
else
{
rb.velocity = movement3.normalized * moveSpeed;
if (Vector3.Distance(transform.position, GameManager.instance.placeToMoveTo.transform.position) < .2f)
{
movement3 = Vector3.zero;
}
}
}
}
}
else
{
rb.velocity = movement2 * moveSpeed;
if (Vector3.Distance(transform.position, meningitisArray[spawnPoint].position) < 2f)
{
movement2 = Vector2.zero;
}
}
}
private void FixedUpdate()
{
// transform.position = new Vector3(transform.position.x, Mathf.Sin(Time.time * freq) * amp, 0);
}
}