this is my code for items:
using UnityEngine;
using System.Collections;
public class Item : MonoBehaviour {
public Transform Inventoy;
public InventoryContoller IC;
void OnMouseEnter()
{
Inventoy.GetComponent<InventoryContoller>().selectedItem = this.transform;
}
}
and this is the inventory controller
using UnityEngine;
using System.Collections;
public class InventoryContoller : MonoBehaviour {
public Transform selectedItem, selectedSlot, originalSlot;
public bool canGrab = false;
void Update () {
if(Input.GetMouseButton(0) && selectedItem != null)
{
selectedItem.position = Input.mousePosition;
}
else if(Input.GetMouseButtonUp(0) && selectedItem != null)
{
selectedItem.localPosition = Vector3.zero;
}
}
}
i dont know why, but thats dont work…
can someone help me?
the inventory controller dont even get the transform from the item script