using UnityEngine;

public class Orbs : MonoBehaviour
{

    public float orbPosX;
    public float orbPosY;
    public float orbPosZ;
    public float maxCheckDistance = 100f;
    public LayerMask groundLayer;
    public float groundOffset = 1f;

    public bool isCollected;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        groundLayer = LayerMask.GetMask("Ground");
        SnapToGround();
        orbPosX = transform.position.x;
        orbPosY = transform.position.y;
        orbPosZ = transform.position.z;

    }

    // Update is called once per frame


    void SnapToGround()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, Vector3.down, out hit, maxCheckDistance, groundLayer))
        {
            Vector3 pos = transform.position;
            pos.y = hit.point.y + groundOffset;
            transform.position = pos;
        }
    }
}
