- Home /
How do I call OnEnable on a CharacterController?
Hi, There is a function that I wanted to call whenever CharacterController got enable. How can I achieve this?
To be more specific, when a Character do certain Animation, the Character will not be affected by Gravity, and will be able to go through certain collider. As such CharacterController will be temporarily disabled.
However, because CharacterController have IgnoreCollision set to it, when it became enable, IgnoreCollision got reset and I have to call it again.
As an alternative, how can I make CharacterController just on this character ignore gravity?
THX
A CharacterController does not implement gravity. Do you have a Rigidbody as well as a CharacterController on the object? What script do you have driving the CharacterController?
Thank you for mentioning that!!! It appeared that the .$$anonymous$$ove() with applied gravity was applied from a different script.
Answer by Levantez · Dec 04, 2013 at 12:20 AM
We sort of got this solved now.
instead of characterController.enabled = false;
we used these instead. characterController.radius = 0.0f; characterController.height = 0.0f;
In addition with fixing motion setting, we got what we wanted to achieve.
However, it should also be note that if we do characterController.center = something then, IgnoreCollision for CharacterController also got reset.