I’ve made a player with a Character Controller
, and no other Collider
.
I am trying to use the function OnTriggerEnter
or OnTriggerStay
, but it doesn’t seem to work with the Character Controller
.
Make sure that the Collider
that is attached to the script object is tagged as Is Trigger
And if it doesn’t work try something like this:
Note: this code is not C#, it’s legacy JS-like language
function OnTriggerStay (Col : Collider)
{
if(Col.tag == "Player")
{
//Do magic
}
}
Attach it to the gameobject that has the Collider
set to Is Trigger
And be sure to tag the player as "Player"
If it doesn’t work post some pictures and explain more what is happening
There is this method for collisions on Character Controller
:
I notice in the docs, under Inherited Members that isTrigger
is actually listed. Perhaps this will actually work to change the CC collider to a trigger? May cause problems, who knows, you can but only try.
The thing is, I am using a character controller - not a rigidbody
– GuadianaMake sure that the Collider
that is attached to the script object is tagged as Is Trigger
And if it doesn’t work try something like this:
Note: this code is not C#, it’s legacy JS-like language
function OnTriggerStay (Col : Collider)
{
if(Col.tag == "Player")
{
//Do magic
}
}
Attach it to the gameobject that has the Collider
set to Is Trigger
And be sure to tag the player as "Player"
If it doesn’t work post some pictures and explain more what is happening
A CharacterController implicitly comes with a collider, but behaves a bit different when it comes to collision callbacks. After some testing in Unity 2021.3.33f I can confirm the following:
OnTriggerEnter
worksOnCollisionEnter
does NOT workOnControllerColliderHit
when moving the CharacterController with Move
So if OnTriggerEnter
is not working for you, double check whether the collider you are colliding against is actually marked as trigger, via the Is Trigger
checkbox on it, or whether your Character Controller has non-zero height/radius. If all that is in order, it should work, otherwise it is most likely a bug in the version you are using.
© 2022 - 2024 — McMap. All rights reserved.
Yeah that's absolutely possible with the runtime APIs and it does it blazingly fast too. Read the API docs here https://brainfail.000webhostapp.com/pivotmodder_runtime_api_docs/html/class_pivot_modder_runtime_1_1_pivot_modder_runtime.html
– Icebound