- Home /
Respawning gameobject not working c#
I have been having a problem with my Unity game in C#. What I am doing currently is having multiple parent gameobject prefabs (thingy 1, thingy 2, thingy 3) (with all their children: Scene 1, Scene 2, Scene 3) being chosen and spawned randomly at a set location using a list. What I want is every time the helicopter gameobject hits one of the childrens collider of the spawned parent gameobject a new gameobject is spawned. However, the colliders don't seem to be working. I have a box collider 2d and a rigidbody 2d attached to the helicopter. On the child gameobject I have just a 2d box collider attacked with the trigger box checked. Every time the helicopter hits the collider attached to the child gameobject, nothing happens! Please tell me what I am doing wrong. Thanks.
A picture of my prefab setting (my description was confusing, I know.):
A picture of the game running with nothing happening:
Code to Respawn (Just in case thats the problem):
using UnityEngine;
using System.Collections;
public class SceneBehaviour : MonoBehaviour {
private SpawnScene spawnScene;
// Use this for initialization
void Start () {
spawnScene = GameObject.Find ("Scene Spawner").GetComponent <SpawnScene> ();
}
void OnTriggerEnter2D (Collider2D col) {
if (col.gameObject.tag == "Helicopter") {
spawnScene.SpawnTheScene ();
Debug.Log ("The collider works");
}
}
// Update is called once per frame
void Update () {
}
}
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Error when transferring items from one list to another 1 Answer
List of Transforms updating all items when adding variable. 1 Answer
How to modify array values? 1 Answer
Agent killing and respanwning 0 Answers