Simulation: An Overnight Closure at MTA 42nd Street Station
Published in
2 min readNov 13, 2019
Argument (Poem):
It is party time on Friday night!
WOOHOO!
But what will happen if the MTA 42nd Street Station close this night?
After working hard the whole week, people would like to get a drink and party with friends. Bars around time square might be ideal choices.
However, …
What if the subway station is closed for a night?
How can people meet their friends at parties at 11 pm?
What are the changes in people’s travel patterns?
Let’s simulate them in Unity!!!
WOOHOO!
Pseudo-code and Unity Code:
# Cube
# Cube Spawn
# Object Pooling
# build an object pool
# recycle when no more object------------------------------------------# cubeusing System.Collections;using System.Collections.Generic;using UnityEngine;public class cube : MonoBehaviour{public float upForce = 1f;public float sideForce = .1f;// Start is called before the first frame updatevoid Start(){float xForce = Random.Range(-sideForce, sideForce);float yForce = Random.Range(upForce / 2f, upForce);float zForce = Random.Range(-sideForce, sideForce);Vector3 force = new Vector3(xForce, yForce, zForce);GetComponent<Rigidbody>().velocity = force;}// Update is called once per framevoid Update(){}}
---------------------------------------------------------------#Cube Spawnusing System.Collections;using System.Collections.Generic;using UnityEngine;public class CubeSpawner : MonoBehaviour{public GameObject cubePrefab;// Start is called before the first frame updatevoid FixedUpdate(){Instantiate(cubePrefab, transform.position, Quaternion.identity);}// Update is called once per framevoid Update(){}}------------------------------------------------------------------