private RaycastHit2D hitInfo;
private GameObject grabbedObject;
private int layerIndex;
void Awake() {
layerIndex = LayerMask.NameToLayer("Objects");
hitInfo = Physics2D.Raycast(transform.position, -transform.right, 2f, layerIndex);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (hitInfo.collider)
{
Debug.DrawRay(transform.position, -transform.right * 2f, Color.green);
Debug.Log(hitInfo.collider.name);
// //Prendre l'item
// if (Keyboard.current.spaceKey.wasPressedThisFrame && grabbedObject == null)
// {
// grabbedObject = hitInfoFridge.collider.gameObject;
// grabbedObject.GetComponent<Rigidbody2D>().isKinematic = true;
// grabbedObject.transform.position = grabPoint.position;
// grabbedObject.transform.SetParent(transform);
// }
// //Rel�cher l'objet
// else if (Keyboard.current.spaceKey.wasPressedThisFrame)
// {
// grabbedObject.GetComponent<Rigidbody2D>().isKinematic = false;
// grabbedObject.transform.SetParent(null);
// // grabbedObject = null;
// // }
} else {
Debug.DrawRay(transform.position, transform.right * 2f, Color.red);
}
}
}