Created
July 17, 2017 16:35
-
-
Save JonathanYin/5fb5f83363153136b7d758e11a6f4199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Pencilline : MonoBehaviour | |
{ | |
//public float explodeRadius = 1f; | |
//to refer to our prefab pencilline | |
public GameObject obj; | |
float lastx = 0f; | |
// Use this for initialization | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
//if we have moved far enough make a new pencilline | |
/*Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, explodeRadius); | |
foreach (Collider2D col in colliders) | |
{ | |
col.isTrigger = false; | |
} | |
*/ | |
if (transform.position.x > (lastx + 0.02f)) | |
{ | |
Instantiate(obj, transform.position, Quaternion.identity); | |
lastx = transform.position.x; | |
lastx = transform.position.x; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is attached to a pencilline object, which is duplicated in the game in order to create a platform for the players to walk on.