- Home /
Character Controller touching other objects
I have a CharacterController and an another object with a collider. I want to at least have a Debug.Log Message, when the CharacterController and the Object touch each other. Yet nothing happens. The Object has its tag, Trigger is on and the CharacterController has a Script like that: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Interacting : MonoBehaviour {
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Character")
{
Debug.Log("touched");
}
}
}
Answer by GDGames0302 · Feb 17, 2021 at 06:26 PM
Hi. You need to use OnControllerColliderHit instead of OnCollisionEnter if you use CharacterController. Here's a link to UnityDocumentation: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnControllerColliderHit.html
I see it is going the right way. It works when the Object the controller is colliding with isn't set to Trigger. Yet I want the Object to be trigger, because its supposed to something like an area in the game and then something should happen.
Your answer
Follow this Question
Related Questions
Bullets colliding with Character Controller 3 Answers
How to fix the position of a character when grabbing a rope? 1 Answer
CharacterController with BoxCollider 1 Answer
OnTrigger events on CharacterController in Unity 3 4 Answers
How to have other (any) Objects smoothly push a Character Controller? 1 Answer