I am trying to make a powerup for my unity game where if the player double taps the screen, the monsters would disappear but i want the second tap on the screen to be in the same position as the first for the monster to be deleted. How do i go about this?
void Update()
{
if (transform.position.y < -15f)
{
Destroy(gameObject);
}
bool doubleTapD = false;
#region doubleTapD
for (int i = 0; i < Input.touchCount; i)
{
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
if (Time.time < _doubleTapTimeD .3f)
{
Destroy(gameObject);
doubleTapD = true;
}
}
_doubleTapTimeD = Time.time;
}
#endregion
if (doubleTapD)
{
Debug.Log("DoubleTapD");
}
}
CodePudding user response:
Sounds like actually you want to track not any touch but rather touches on the monster object itself.
Therefore I would actually rather recommend using
There are many (video) tutorials showing how to get started with the InputSystem.