- Home /
how can i make it so my blocks switch from grass to log because i have a switch script but i cant make the 2 blocks turn on and off for placing please help
using UnityEngine; using System.Collections;
public class WorldGenerator : MonoBehaviour { public GameObject grass; public GameObject log; public GameObject current;
public float SizeX;
public float SizeZ;
public float SizeY;
// Use this for initialization
void Start()
{
StartCoroutine(SimpleGenerator());
}
void Update()
{
}
public static void CloneAndPlace(Vector3 newPosition, GameObject originalGameobject)
{
GameObject current = (GameObject)Instantiate(originalGameobject, newPosition, Quaternion.identity);
current.transform.position = newPosition;
current.name = "Block";
}
IEnumerator SimpleGenerator()
{
uint numberOfInstances = 0;
uint instancesPerFrame = 50;
float height = Random.Range(0, SizeY);
for (int y = 0; y <= height; y++)
{
numberOfInstances++;
if (numberOfInstances == instancesPerFrame)
{
numberOfInstances = 0;
yield return new WaitForEndOfFrame();
}
}
}
}
Hello Welcome to Unity Answers, You're question is currently in $$anonymous$$oderation.
Looking at your question , here are some key points that can help improve your question. - you have a very bloated title. Titles should be brief but specific - you provide very little detail on the problem - guessing from your title, you had actually have more than one question. one of those is listed here http://answers.unity3d.com/questions/396725/switching-between-two-objects-using-enable.html - You're script is not formatted correctly,
if you fix these things , and add some more specific details to your problem another moderator will like publish this question.
Your answer
Follow this Question
Related Questions
Script isn't disabling? 1 Answer
Script has been enabled during the gameplay, but never called. 0 Answers
Wave manager that enables multiple gameobjects after X seconds? 0 Answers
Enable & Disable multiple game objects 0 Answers
Have objects persist in one scene, and not across all scenes? (C#) 0 Answers