I have used this script and everything worked fine. But now does not work, I can’t understand what happened. I think it is an error on Unity. What do you think?
#pragma strict
var mainPrefab : GameObject;
var secondPrefab : GameObject;
var thirdPrefab : GameObject;
var fourthPrefab : GameObject;
function OnTriggerEnter2D(other:Collider2D)
{
switch( Random.Range(0,4))
{
case 01:secondPrefab.transform.position.x = mainPrefab.transform.position.x +(35); secondPrefab.transform.position.y = -1.7; Debug.Log("One"); break;
case 02:thirdPrefab.transform.position.x = mainPrefab.transform.position.x +(35); thirdPrefab.transform.position.y = -1.7; Debug.Log("Two"); break;
case 03:fourthPrefab.transform.position.x = mainPrefab.transform.position.x +(35); fourthPrefab.transform.position.y= -1.7; Debug.Log("three"); break;
}
}
I make a 2D Endless Runner. I want spawn the platform where the character run. But now doesn’t work anymore.