I need some help. I have done of some drag and drop stuff, but now comes the hard part. I need to make the tokens return a value of one when it’s on top of a character. Here is the script that I have for the drag and drop, just to let you guys know what I’m doing:
public class PlayerOneToken : MonoBehaviour, IPointerDownHandler, IBeginDragHandler, IEndDragHandler, IDragHandler
{
[SerializeField] private Canvas canvas;
private RectTransform Token;
void Awake()
{
Token = GetComponent<RectTransform>();
}
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("OnBeginDrag");
}
public void OnDrag(PointerEventData eventData)
{
Debug.Log("OnDrag");
Token.anchoredPosition += eventData.delta / canvas.scaleFactor;
}
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("OnEndDrag");
}
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("OnPointerDown");
}
}
Now in this code, I want to have a return value of 1, the moment it gets slapped on a character. Any help is appreciated.