Open cancaglar opened 1 year ago
Which platform is this?
Hi @cancaglar ,
Don't use the method OnMouseDown() on phones, this will not work on all devices also you can get a lot of errors, for tapping interaction use in Update() --- >Input.touch
void Update()
{
if (Input.touchCount > 0)
{
m_touch = Input.GetTouch(0);
//logic on Tap
print("TAP");
if (m_touch.phase == TouchPhase.Began)
{
var hit = new RaycastHit();
Ray ray = m_mainCamera.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out hit, m_maxDistanceHit))
{
Debug.Log(hit.transform.gameObject.tag);
if (hit.transform.gameObject.tag == "PLAYER")
{
Debug.Log("SOME ACTION ON TAPPING ON PLAYER");
}
UnityMessageManager.Instance.SendMessageToFlutter($"action#{hit.transform.gameObject.tag}");
}
}
}
}
Which platform is this?
android
Hi @cancaglar ,
Don't use the method OnMouseDown() on phones, this will not work on all devices also you can get a lot of errors, for tapping interaction use in Update() --- >Input.touch
void Update() { if (Input.touchCount > 0) { m_touch = Input.GetTouch(0); //logic on Tap print("TAP"); if (m_touch.phase == TouchPhase.Began) { var hit = new RaycastHit(); Ray ray = m_mainCamera.ScreenPointToRay(Input.GetTouch(0).position); if (Physics.Raycast(ray, out hit, m_maxDistanceHit)) { Debug.Log(hit.transform.gameObject.tag); if (hit.transform.gameObject.tag == "PLAYER") { Debug.Log("SOME ACTION ON TAPPING ON PLAYER"); } UnityMessageManager.Instance.SendMessageToFlutter($"action#{hit.transform.gameObject.tag}"); } } } }
Yes this is exactly what I did. But this is kind of weird issue.
This function is not working when I use this flutter package