// FixedUpdate is called once every physics time step. This is the place to do physics-based game behaviour.
    void FixedUpdate()
    {
        switch (currentBOState)
        {
            case BuildingObjectState.MOVING:
            {
                if (GetHasUser() && User.UsedObject == this)
                {
                    UpdatePosition();
                    if (Time.time - lastUsedTime > 0.1f)
                    {
                        SetCollidersInactive(true);
                        UpdateMaterialColors();
                    }

                    if (bIsGrounded)
                        bIsGrounded = false;

                    // If the rotation vector has been set by player controller
                    if (RotationVector != Vector3.zero)
                        currentBOState = BuildingObjectState.ROTATING;
                }
                else
                {
                    lastPlacedTime = Time.time;
                    currentBOState = BuildingObjectState.PLACED;
                }
            }break;

            case BuildingObjectState.ROTATING:
            {
                if (GetHasUser() && User.UsedObject == this)
                {
                    UpdateRotation();
                    SetCollidersInactive(true);
                    UpdateMaterialColors();

                    if (RotationVector == Vector3.zero || Vector3.Distance(this.transform.position, User.transform.position) > (HoldingDistance*1.5f))
                        currentBOState = BuildingObjectState.MOVING;
                }
                else
                {
                    lastPlacedTime = Time.time;
                    currentBOState = BuildingObjectState.PLACED;
                }
            }break;

            case BuildingObjectState.PLACED:
            {
                if (!GetHasUser())
                {
                    SetCollidersInactive(false);
                    UpdateMaterialColors();

                    if (Time.time - lastPlacedTime > 1f)
                    {
                        if (!bHasBeenPlaced)
                            bHasBeenPlaced = true;
                    }

                    if (bIsGrounded)
                    {
                        if (Time.time - lastGroundedTime > SecondsToKinematic)
                        {
                            foreach (Rigidbody rBody in rigidbodies)
                            {
                                if (!rBody.isKinematic)
                                    rBody.isKinematic = true;
                            }

                            currentBOState = BuildingObjectState.PLACED_SOLID;
                        }
                    }
                }
                else
                {
                    if (User.UsedObject == this)
                    {
                        lastUsedTime = Time.time;
                        currentBOState = BuildingObjectState.MOVING;
                    }
                    else
                    {
                        Debug.LogWarning("GetHasUser() but UsedObject != this");
                    }
                }
            }break;

            case BuildingObjectState.PLACED_SOLID:
            {
                if (GetHasUser())
                {
                    if (User.UsedObject == this)
                    {
                        lastUsedTime = Time.time;
                        currentBOState = BuildingObjectState.MOVING;
                    }
                    else
                    {
                        Debug.LogWarning("GetHasUser() but UsedObject != this");
                    }
                }

            }break;
        }
    }
    void Start()
    {
        Material[] mats = this.renderer.materials;
        if (mats.Length > 0)
        {
            originalColors = new Color[mats.Length];
            bCanUseColors = true;
            for (int i = 0; i < mats.Length; i++)
            {
                originalColors.SetValue(mats[i].color, i);
            }
        }

        if (bRotateRandomOnStart)
            this.transform.rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);

        InitColliders();
        SetCollidersInactive(true);

        if (GetHasUser())
            currentBOState = BuildingObjectState.MOVING;
    }