I have a capsule object with Camera on it. Capsule has capsule collider with mesh, character controller. cylinder object (coin) is box collider with is trigger option being on. OnTriggerObject method doesn’t help to destoy the coin object. Even used OnCollisionEnter, eventually have the same result. Also tried with rigidbody added to the player object and removed from coin object. Even don’t remember what I tried on.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
void Start()
{
controller = GetComponent<CharacterController>();
if (lockCursor)
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
// Update is called once per frame
void Update()
{
UpdateMouseLook();
UpdateMovement();
}
private void OnControllerColliderHit(ControllerColliderHit other)
{
if(other.gameObject.tag == "coins")
{
Destroy(other.gameObject);
}
}
}