Skip to content

Instantly share code, notes, and snippets.

@muddokon
Created August 16, 2019 00:13
Show Gist options
  • Save muddokon/ae2a3c42c7f464fbb8d0bba58f746854 to your computer and use it in GitHub Desktop.
Save muddokon/ae2a3c42c7f464fbb8d0bba58f746854 to your computer and use it in GitHub Desktop.
Pooled Object with movement for Unity
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PooledObject : MonoBehaviour
{
public float speed;
public string limitTag;
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag(limitTag))
{
gameObject.SetActive(false);
}
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.right * Time.deltaTime * speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment