hello, I'm new here, and I have a problem.
I've been working through unity trying to create a bomberman/melonbomber hybrid, and I'm having a hard time getting the boxes to load into the grid. I've made an array of "node" game objects that i'd like to spawn a single "box" object to on a random chance.
I am not very knowledgeable of unity or C# but I really want to make this work.
Right now it doesn't work at all because it doesn't know where the nodes are or if it should or shouldn't put something there. I just added a variable that isn't right that i'm changing as we speak, but I know I'm doing this completely wrong and I'd love to get past this and work on the explosions!
Last edited by lostecho on Mon Feb 15, 2016 12:42 pm; edited 1 time in total (Reason for editing : possibly unclear wording)
I've been working through unity trying to create a bomberman/melonbomber hybrid, and I'm having a hard time getting the boxes to load into the grid. I've made an array of "node" game objects that i'd like to spawn a single "box" object to on a random chance.
I am not very knowledgeable of unity or C# but I really want to make this work.
Code:
using UnityEngine;
using System.Collections;
public class spawnBoxes : MonoBehaviour
{
public Transform[] spawnNodes;
private float Nodeindex;
void Start ()
{
GameObject prefab = Resources.Load ("box") as GameObject;
spawnNodes = new Transform[64];
for (int i=0;i<64;Nodeindex=i++)
{
GameObject go = Instantiate(prefab,spawnNodes[Nodeindex].transform.position,Quaternion.Euler(0,0,0)) as GameObject;
go.transform.position = new Vector3 (5, 5, 5);
}
}
}
Right now it doesn't work at all because it doesn't know where the nodes are or if it should or shouldn't put something there. I just added a variable that isn't right that i'm changing as we speak, but I know I'm doing this completely wrong and I'd love to get past this and work on the explosions!
Last edited by lostecho on Mon Feb 15, 2016 12:42 pm; edited 1 time in total (Reason for editing : possibly unclear wording)