Continuing the theme of "turning this thread into a code analysis thread"
If anyone who is still interested in modding this game
Here is my "failed attempt" on creating a "press button to spawn monster"
Code:
GameObject[] Spawn_Mon;
int Spawn_Mon_Length
int Spawner_Random
Vector3 Spawn_Mon_Local
//// Need to find the right location to place these ////
Spawn_Mon = GameObject.FindGameObjectsWithTag("Mon");
Spawn_Mon_Length = Spawn_Mon.Length;
///////
//// I put these in the GameManager ////
if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter)) //Change to any key you want
{
Spawn_Mon_Local = new Vector3(GameObject.Find("Player").transform.position.x + 5f, GameObject.Find("Player").transform.position.y, 0f); // Change to any value you want
Spawn_Mon_Random = UnityEngine.Random.Range(0, this.Spawn_Mon_Length);
GameObject gameObject = UnityEngine.Object.Instantiate(Spawn_Mon[Spawn_Mon_Random], Spawn_Mon_Local, base.transform.rotation) as GameObject;
gameObject.transform.parent = base.transform.parent;
}
My plan is to a way to "instantiate" a monster that set to spawn in that particular room, which, if possible, may be able to expand further to spawn any monster in the game at player's location
So far, I only managed to spawn
1. Hatched egg
2. Tentacle that do nothing to player
and
Code:
NullReferenceException
at (wrapper managed-to-native) UnityEngine.Object:INTERNAL_CALL_Internal_InstantiateSingle (UnityEngine.Object,UnityEngine.Vector3&,UnityEngine.Quaternion&)
at UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) [0x00000] in <filename unknown>:0
at UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) [0x00000] in <filename unknown>:0
at GameManager.Spawner () [0x00000] in <filename unknown>:0
at GameManager.Update () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
I hope that someone with too many free time stumble on this and continue further and make this become reality