Quantcast
Channel: Questions in topic: "tap"
Viewing all articles
Browse latest Browse all 171

How do I have the user fast tap on an AR object 10 times (in a certain amount of time) in order to trigger an animation?

$
0
0
The main idea of my game is to have a floating AR object. I want the user to fast tap on the object a certain number of times (ex. Tap 10 times) to trigger an animation. I'm pretty sure that the idea is to count the number of Raycast hits on the object in a certain amount of time. But I don't know how to do that. (Using Vuforia) Here is the code I have so far. All it does at the moment is plays a particle animation with sound when the ball is tapped on the iphone screen (AR). public void Update() { if (Input.GetMouseButton(0)) { Vector3 mousePosFar = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.farClipPlane); Vector3 mousePosNear = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane); Vector3 mousePosF = Camera.main.ScreenToWorldPoint(mousePosFar); Vector3 mousePosN = Camera.main.ScreenToWorldPoint(mousePosNear); //Debug.DrawRay(mousePosN, mousePosF - mousePosN, Color.green); RaycastHit hit; if (Physics.Raycast(mousePosN, mousePosF - mousePosN, out hit)) { //Plays cartoon punch sounds when ball is tapped moneyhitsounds = GetComponent(); //int ran = Random.Range(0,5); moneyhitsounds.clip = hitsounds[0]; moneyhitsounds.Play(); //Plays the dollar bill animation when moneyball is tapped collectParticle.Play(); } } }

Viewing all articles
Browse latest Browse all 171

Latest Images

Trending Articles





Latest Images