- Home /
Is there a way to properly detect collisions on Character Controller?
I currently doing game similiar to Wipe Out I could say. You have different levels with moving and rotating obstacles and when you touch them you die. I've been doing my player movement with Character Controller, because I heard it's easier to do and you can climb slopes and stairs without any programming. So I used OnControllerColliderHit, but it's only working if you are moving. You basically need to collide with something not something with you if I understand it correctly. My question is: Is there some better way to do the collisions with Character Controller or do I need to use RigidBody?
If this is really the best way to do collisions with Controller, isn't kinda useless? I'll be happy for any correction.
Answer by sinrin · Jul 13, 2021 at 06:00 PM
Rigidbodies in Unity "go to sleep" by default when they aren't moving to save computation. Go to the Rigidbody properties in the inspector where it says Sleeping Mode and change that to "Never Sleep".
Hope that helps @RandomaaK
he's using a character controller and OnTriggerEnter() solved his problem....but still ..i didn't know that and this is actually very helpful, thanks!
Answer by dero273 · Jul 13, 2021 at 02:03 PM
Try
OnCollisionEnter(Collision other)
{
If (other.Gameobject.CompareTag("TheTaggOffYourMovingObjects"))
{
YourMethodeToDie()
}
}
Note: its maybe not written exactly right but maybe u got the idea.
Link to Unity's Scripting API: https://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
Your answer
