Question by
Villalosers · Apr 28, 2017 at 05:50 AM ·
gameobjectscriptingproblem
Cant put Script on GameObject, Help!
I am watching the creating a basic platformer on unity tutorials, and when I have to put the scriptmanager script I cant put the script, I did it on the scripts folder, didnt work, and tried by adding component on spawnmanager and it doesnt work, help please, this is the code i put:
using UnityEngine; using System.Collections;
public class SpawnPlatforms : MonoBehaviour {
public int maxPlatforms = 20;
public GameObject platform;
public float horizontalMin = 7.5f;
public float horizontalMax = 14f;
public float verticalMin = -6f;
public float verticalMax = 6;
private Vector2 originPosition;
void Start () {
originPosition = transform.position;
Spawn ();
}
void Spawn()
{
for (int i = 0; i < maxPlatforms; i++)
{
Vector2 randomPosition = originPosition + new Vector2 (Random.Range(horizontalMin, horizontalMax), Random.Range (verticalMin, verticalMax));
Instantiate(platform, randomPosition, Quaternion.identity);
originPosition = randomPosition;
}
}
}
Comment