Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » I need help creating a script for generating boxes in a bomberman clone.

I need help creating a script for generating boxes in a bomberman clone.

Go down  Message [Page 1 of 1]


Member [Lv. 0]
Member [Lv. 0]
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.

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)

View user profile

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum