Using a different Character Controller
Things to remember:
//My included player controller script
[Header("Control Toggles")]
public bool canMove = true; // Enables/disables player movement
public bool canRotate = true; // Enables/disables camera rotation
private void Update()
{
// Exit if no input handler is found
if (inputHandler == null) return;
// Handle movement, rotation, crouching, and footsteps if enabled
if (canMove) HandleMovement();
if (canRotate) HandleRotation();
HandleCrouching();
HandleFootsteps();
}
public void SetPlayerDisableMode(bool active)
{
canMove = !active;
canRotate = !active;
}
private void RotateObject()
{
// don’t even start rotation if this object says no
if (!heldObject.CanRotate) return;
bool rotating = inputHandler.RotateHeldPressed();
// fire event when start/stop rotating
if (rotating != wasRotating)
{
onRotateModeChanged?.Invoke(rotating);
wasRotating = rotating;
}
Last updated