Search Unity

How do I script 3D runner jump Left, Right, Slide? Please help.

Discussion in 'Scripting' started by sean4mvo, Feb 28, 2015.

  1. sean4mvo

    sean4mvo

    Joined:
    Jan 5, 2015
    Posts:
    15
    I have this as my script (any tips?)
    ------I have this as a my error-----
    Assets/MoveRoads/MoveRoads.cs(8,17): error CS0246: The type or namespace name `LinkedList' could not be found. Are you missing a using directive or an assembly reference?

    using UnityEngine;
    using System.Collections;

    public class MoveRoads : MonoBehaviour {

    public Transform prefab;

    private LinkedList items = new List();

    private float posY = 0.0f;
    private int numberOfRoads = 3;

    // Use this for initialization
    void Start () {

    //Init the sccene with some road-pieces
    for(int i=0;i < numberOfRoads;i++) {
    Transform road = Instantiate(prefab) as Transform;
    road.Translate (0, posY, i * road.localScale.z);
    MoveRoads.AddLast(road);
    }
    }

    // Update is called once per frame
    void Update () {

    Transform firstRoad = roads.First.Value;
    Transform lastRoad = roads.Last.Value;

    // Create a new road if the first one is not
    // in sight anymore and destroy the first one
    if(firstRoad.localPosition.z < -5f) {

    roads.Remove(firstRoad);
    Destroy(firstRoad.gameObject);

    Transform newRoad = Instantitate(prefab, new Vector3(0, posY ,
    lastRoad.localPosition.z + lastRoad.localScale.z),
    Quaternion.identity) as Transform;
    roads.Addlast(newRoad);

    }

    // Move the available roads along the z-axis
    foreach(Transform road in roads) {
    road.Translate(0,0, -8f * Time.deltaTime);
    }

    }
    }
     
  2. jallen720

    jallen720

    Joined:
    Feb 22, 2015
    Posts:
    66
    Please read this and edit your post so your code is readable.
    Also, LinkedList is in System.Collections.Generic
     
  3. sean4mvo

    sean4mvo

    Joined:
    Jan 5, 2015
    Posts:
    15
    Many thanks jallen your awesome wont forget.