Skip to content

Instantly share code, notes, and snippets.

@JonathanYin
Created July 17, 2017 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanYin/5fb5f83363153136b7d758e11a6f4199 to your computer and use it in GitHub Desktop.
Save JonathanYin/5fb5f83363153136b7d758e11a6f4199 to your computer and use it in GitHub Desktop.
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;
}
}
}
@JonathanYin
Copy link
Author

JonathanYin commented Jul 17, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment