using System.Collections; using System.Collections.Generic; using UnityEngine; public class Treadmill : MonoBehaviour { Rigidbody2D rb; public float treadmillSpeed = 1.0f; // Start is called before the first frame update void Start() { rb = GetComponent(); } // Update is called once per frame private void OnTriggerStay2D(Collider2D collision) { GameObject otherObject = collision.gameObject; if(otherObject.tag == "treadmillUp") { rb.velocity = new Vector2(0, treadmillSpeed); } if (otherObject.tag == "treadmillDown") { rb.velocity = new Vector2(0, -treadmillSpeed); } if (otherObject.tag == "treadmillLeft") { rb.velocity = new Vector2(-treadmillSpeed, 0); } if (otherObject.tag == "treadmillRight") { rb.velocity = new Vector2(treadmillSpeed, 0); } } }