Beispiel #1
0
    void FixedUpdate()
    {
        if (!userController.mouseClickObject)
        {
            // if (!userController.isDropped)

            Ray        blockRayMin = new Ray(transform.position, Vector3.down);
            RaycastHit blockRayMinHit;
            Ray        blockRayMax = new Ray(transform.position, Vector3.down);
            RaycastHit blockRayMaxHit;


            // Debug.DrawRay (transform.position, Vector3.down * blockRayMinHeight);
            // Debug.DrawRay (transform.position, Vector3.down * blockRayMaxHeight);

            // Check if MinRay is hit
            if (Physics.Raycast(blockRayMin, out blockRayMinHit, blockRayMinHeight))
            {
                // If MinRay is hit, block should be moved up:
                userController.MoveUpSpawnedObject();

                // Redundant code (?) - Checks distance from org pos to Ray hit.
                //distanceMeasured = hit.distance;
            }

            // If MaxRay is hit when MinRay is NOT hit
            else if (Physics.Raycast(blockRayMax, out blockRayMaxHit, blockRayMaxHeight))
            {
                // spawnerScript.SpawnNext ();
            }
            else                 // If MinRay is NOT hit AND MaxRay is NOT hit
            {
                userController.MoveDownSpawnedObject();
            }
        }
    }