Floor Collision Question

I am just getting started with game development in Unity, and I’m going through the book “Unity In Action 3rd Edition”. The book itself is great; it’s helping me get acquainted with the Unity Editor, and teaching me some programming concepts I’m not already familiar with. But I’m running into an issue, and I’m not sure how to correct this. Hence, the forum post.

In the book, we create a player object and attach several scripts to it for input (mouse and keyboard). The object itself has a transform scale of 1, 1, 1 (x, y, z), and the Character Controller component has a height of 2. The scripts that control movement are fairly simple:

Mouse

using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Security.Cryptography;
using UnityEngine;

public class MouseLook : MonoBehaviour
{
    public enum rotationAxes
    {
        MouseXAndY = 0,
        MouseX = 1,
        MouseY = 2
    }

    public rotationAxes axes = rotationAxes.MouseXAndY;
   
    public float sensitivityHor = 9.0f;
    public float sensitivityVert = 9.0f;

    public float minimumVert = -45.0f;
    public float maximumVert = 45.0f;

    private float verticalRot = 0;

    // Start is called before the first frame update
    void Start()
    {
        Rigidbody body = GetComponent<Rigidbody>();
        if (body != null)
        {
            body.freezeRotation = true;
        }
    }

    // Update is called once per frame
    void Update()
    {
        if (axes == rotationAxes.MouseX)
        {
            //Horizontal rotation code
            transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityHor, 0);
        }
        else if (axes == rotationAxes.MouseY)
        {
            //Vertical rotation code
            verticalRot -= Input.GetAxis("Mouse Y") * sensitivityVert;
            verticalRot = Mathf.Clamp(verticalRot, minimumVert, maximumVert);

            float horizontalRot = transform.localEulerAngles.y;
            transform.localEulerAngles = new Vector3(verticalRot, horizontalRot, 0);
        }
        else
        {
            //Horizontal and vertical rotation code
            verticalRot -= Input.GetAxis("Mouse Y") * sensitivityVert;
            verticalRot = Mathf.Clamp(verticalRot, minimumVert, maximumVert);

            float delta = Input.GetAxis("Mouse X") * sensitivityHor;
            float horizontalRot = transform.localEulerAngles.y + delta;

            transform.localEulerAngles = new Vector3(verticalRot, horizontalRot, 0);
        }
    }
}

Keyboard

using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Threading;
using UnityEngine;

[RequireComponent(typeof(CharacterController))]
[AddComponentMenu("Control Script/FPS Input")]

public class FPSInput : MonoBehaviour
{
    public float speed = 12.0f;
    public float gravity = -9.8f;

    private CharacterController charController;

    // Start is called before the first frame update
    void Start()
    {
        charController = GetComponent<CharacterController>();
    }

    // Update is called once per frame
    void Update()
    {
        float deltaX = Input.GetAxis("Horizontal") * speed;
        float deltaZ = Input.GetAxis("Vertical") * speed;
        Vector3 movement = new Vector3(deltaX, 0, deltaZ);

        movement = Vector3.ClampMagnitude(movement, speed);
        movement.y = gravity;
        movement *= Time.deltaTime;
        movement = transform.TransformDirection(movement);

        charController.Move(movement);
    }
}

As an aside, the Axis on the mouse script is set to Mouse X, and there is a second instance of this script attached to the main camera that is positioned on top of the player object to allow for Mouse Y.

This all works just fine, and I can use mouse input to look around and keyboard input to move. And I stay on the floor, with gravity keeping me there and not allowing me to fly around.

I want to alter the size of the player object so it is in line with the scale of the room it is in. The room has an outer size of 50 x 50, with a wall height of 10. If that’s feet, the scale of the player should be 6 (to keep things lined up), with a total diameter of 6 (3 in all directions). However, when I change any of the values in the Unity Editor (Player Transform Scale x/y/z, Character Controller Height/Radius), the player object immediately falls through the floor at runtime. Setting these values back to the original values I stated earlier prevents this, but any change in them and the object falls through the floor.

So what is it that I am doing wrong here? What other value/parameter needs to be set so that the object can be sized appropriately for the scene, but so that it doesn’t fall through the solid object it is supposed to be standing on? Does the object need to have its values set before attaching a script to it?

And I derped on this. Needed to move the object along the y axis relative to the change in size.