Hi, Im working on collect trophy system and the tutorial I watched is using GetMouseButton and mousePosition to get the input. Since Im doing mobile game application, the function for the input did not works on my script. Here is my script, I just want to know how to replace mouse input to mobile input. Thankyou
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GetTrophy : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
CollectTrophy();
}
public void CollectTrophy()
{
if (Input.GetMouseButton(0))
{
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if (hit.collider != null)
{
PlayerPrefs.SetInt(hit.collider.name, 1);
Destroy(hit.collider.gameObject);
}
}
}
}