// Update is called once per frame
void FixedUpdate()
{
RaycastHit objHit;
bool hit = Physics.Raycast(transform.position, transform.forward, out objHit);
if (hit)
{
if (objHit.distance > interactionDistance)
{
NoticeObject("object is to far away to interact!");
return;
}
Interactive interaction = objHit.transform.gameObject.GetComponent <Interactive>();
if (interaction == null)
{
NoticeObject("object is not interactive!");
}
else if (Input.GetMouseButtonDown(0))
{
interaction.Interact();
}
else
{
NoticeObject("Click to interact!");
}
}
else
{
Debug.Log("no ray hits!");
NotificationManager.inst.RemoveNotification(notifKey);
}
}