- Home /
CharacterController.Move problem with pause menu
When I pause my game I get that warning popping up. I don't know if it's even worth fixing as the game itself works fine. Here's my code (that matters):
if (Input.GetKeyDown(KeyCode.Escape))
{
if (pauseMenuOpen == false)
{
audio.PlayOneShot(clickSound);
playerPosX = player.transform.position.x;
playerPosY = player.transform.position.y-.4;
playerPosZ = player.transform.position.z;
OpenPauseMenu();
pauseMenuOpen = true;
}
function OpenPauseMenu () {
player.GetComponent(CharacterController).enabled = false;
Time.timeScale = 0;
Screen.lockCursor = false;
player.transform.position = Vector3(playerPosX, playerPosY, playerPosZ);
}
If i don't turn off the character controller and the player is moving and pauses the game it returns null values for some variables and nothing seems to fix it. The "playerPosX" variables are used to set the position of the player because unity seems to lose track of the object and assigns it a y position than what it was previously at when i turn off the character controller.
If anyone knows how to fix the CharacterController.Move called on inactive controller UnityEngine.CharacterController:Move(Vector3) problem without completely reworking my code it would be greatly appreciated. If there is no solution, is it bad to have the constant warnings like it's giving me?
Thanks
We can't help you unless you actually post the code relevant to the question. You get a warning about calling $$anonymous$$ove
when you shouldn't be, so why don't you post the code where you call $$anonymous$$ove
from? Or at least explain when that gets called?
@Benproductions1 What do you mean? I'm disabling the character controller while the pause menu is open and the character controller is just the standard character controller that comes with unity.
I get the error calling move on a character controller that is disabled, I'm just looking for a work around or something that makes the warning go away
Press ctrl-f, type in .$$anonymous$$ove(
. Is it in the code you posted? No. Is it necessary for your question to be answered, Yes. So why not post it?
Also, why not just check whether the character controller is disabled before calling $$anonymous$$ove
?
The .$$anonymous$$ove is all over the place in the Character $$anonymous$$otor, I wouldn't know how to paste it into a coherent post that everyone can understand. And I know why I'm getting the error, it's because I'm telling something to move when it shouldn't be able to and my guess is Unity is getting confused. I'm not asking for a solution so to speak because the code works but more how do I just get rid of the warning because my code isn't giving me any problems except that.
The way to get rid of the warning is to solve the problem. Now that you've finally told us how you are controlling the CharacterController
, my suggestion is to disable the Character$$anonymous$$otor
(and anything using it) when you disable the CharacterController
. Better yet, you only need to disable the script that ultimately controls the movement.
Answer by DoctorMoney · Dec 29, 2013 at 01:04 AM
Fixed it, problem was I had a script that was active that depended on the Character Motor so it would always re enable itself for anyone who might look at this in the future. Check your scripts
Answer by jDixon793 · Dec 28, 2013 at 06:20 PM
If the Character Motor is where the move is being called maybe try disabling the script when you are paused? GetComponent<CharacterMotor>().enabled = false;
Tried that, it just reenables itself and keeps giving me the warning @jDixon793
Your answer
Follow this Question
Related Questions
Multiply deltaTime to arrive at point2 in 1.5 sec ? 1 Answer
Fail with movedirection of Character Controller 1 Answer
why does character controller accelerate off ledges? 1 Answer
Pushing a character controller (physics interaction) 0 Answers
Using .move(), the enemy moves faster at a diagonal 2 Answers