Hello, just working on my game. So, I found that calling _characterController.SimpleMove(Vector3.zero);
Unity freezes and becomes unresponsive. The only way to restart it is just to kill the process.
Tried on Unity 2021.3.x and 2022.1. Both are Silicon edition.
private void Update()
{
if (_isMovementStopped)
{
return;
}
//Debug
if (_controlType == GameSettingsScript.ControlType.TwoFingerGestures)
{
_gamePlayUIScript.EnableLeftControl(_primaryTouchIsActive);
_gamePlayUIScript.EnableRightControl(_secondaryTouchIsActive);
}
var playerSpeed = _playerSpeed + (_playerSpeedPowerupRate * (_isPowerUpSpeed ? 1f : 0f));
var turnSpeed = _playerTurnSpeed;
Vector2 movementDirection = _movementDirection;
if (_controlType == GameSettingsScript.ControlType.TwoFingerGestures)
{
turnSpeed = _playerLookSpeed;
}
var sensitivityScale = ControllerSensitivityScale;
float sen = sensitivityScale * (_controllerSensitivity);
if (_isGrounded)
{
var maxSpeed = Math.Max(Math.Abs(movementDirection.y), Math.Abs(_steering.x));
_playerAnimator.SetFloat(MoveSpeed, maxSpeed);
}
var moveDirection = transform.forward * (movementDirection.y * playerSpeed * Time.smoothDeltaTime);
gameObject.transform.Rotate(0, movementDirection.x * (turnSpeed * sen) * Time.smoothDeltaTime, 0);
if (_controller)
{
_controller.Move(moveDirection + new Vector3(0f, _verticalVelocity, 0f) * Time.smoothDeltaTime);
}
if (_controller.isGrounded && _controller.velocity.magnitude > 2.0f)
{
AudioManager.Instance.PlayFootSteps();
}
}
The idea of calling SimpleMove is just to stop the player while “teleporting” to some position.
The code is far from the production level, as some R&Ds in progress.
Your problem is far more likely because you’re calling the move from within OnTriggerEnter.
Also, you’re mixing and matching physics / collision stuff (OnTriggerEnter, which implies Rigidbody, which IS Physics) with CharacterController.
Pick one. They don’t play well together and were never meant to play well together.
If you pick physics, then you must NEVER manipulate the transform directly because you bypass physics.
With Physics (or Physics2D), never manipulate the Transform directly. If you manipulate the Transform directly, you are bypassing the physics system and you can reasonably expect glitching and missed collisions and other physics mayhem.
Always use the .MovePosition() and .MoveRotation() methods on the Rigidbody (or Rigidbody2D) instance in order to move or rotate things. Doing this keeps the physics system informed about what is going on.
With a wheel collider, use the motor or brake torque to effect motion.
If you just need a handy starter character controller, here is a super-basic starter prototype FPS based on Character Controller (BasicFPCC):
That one has run, walk, jump, slide, crouch… it’s crazy-nutty!!