Hello! I have a part of a game code that should work when put on a wordpress site. Right now it is only responding to touch, but not mouse button click. How should I go about converting this code to work with mouse click?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NoCrash : MonoBehaviour
{
bool moveAllowed;
Collider2D col;
// Start is called before the first frame update
void Start()
{
col = GetComponent<Collider2D>();
}
// Update is called once per frame
void Update()
{
if (Input.touchCount>0)
{
Touch touch = Input.GetTouch(0);
Vector2 touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
if (touch.phase == TouchPhase.Began)
{
Collider2D touchedCollider = Physics2D.OverlapPoint(touchPosition);
if (col == touchedCollider)
{
moveAllowed = true;
}
}
if (touch.phase == TouchPhase.Moved)
{
if (moveAllowed)
{
transform.position = new Vector2(touchPosition.x, touchPosition.y);
}
}
if (touch.phase == TouchPhase.Ended)
{
moveAllowed = false;
}
}
}
}