So while I was searching on the internet I actually found alot of answers to this, but I don’t quite understand it; and when I tried it I got the error ‘Object reference not set to an instance of an object’
So, bassicly this is what I have:
-a wall Prefab, with a code telling it to move down with a wallspeed
-the wall spawner, spawning the prefabs every x few seconds.
I added a timer to the wall spawner, and I based on time elapsed have stuff happen, Like change score, or increase speed of the wall prefab.
I don’t understand why this is so dificult to do in coding, I remember when I was learning actionscript 3 I also had massive problems accessing other functions and variables in other scripts…
this is the code what I have for the wallspawn:
using UnityEngine;
using System.Collections;
public class wallSpawn : MonoBehaviour
{
public GameObject Wall;
public float spawnTimeLimit = 1f; // 10 seconds.
public float timePassed = 0f;
// Use this for initialization
void Start ()
{
GameObject theWalls = GameObject.Find("Wall");
wallScript wallscript = theWalls.GetComponent<wallScript>();
wallscript.wallSpeed = 50f;
//this is what is causing the trouble, I got this from the internet but dind't help.
}
// Update is called once per frame
void Update ()
{
The wall prefab just has a transform.translate(0, -wallSpeed… etc.
Thank you in advance!