using System.Collections; using System.Collections.Generic; using UnityEngine; public class CollisionTest : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { //StartCoroutine(move()); } void OnControllerColliderHit(ControllerColliderHit hit) { Debug.Log("CC::Collision!"); } private void OnTriggerEnter(Collider other) { Debug.Log("BOX::Collision!"); } IEnumerator move() { while (true) { transform.Translate(Vector3.left * 2 * Time.deltaTime); yield return new WaitForSeconds(3f); transform.Translate(Vector3.right * 2 * Time.deltaTime); yield return new WaitForSeconds(3f); } } }