Created
August 16, 2019 00:13
-
-
Save muddokon/ae2a3c42c7f464fbb8d0bba58f746854 to your computer and use it in GitHub Desktop.
Pooled Object with movement for Unity
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 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