- Home /
Move object faster when the screen is tapped repeatedly
Hello, I'm trying to move a 2d object upwards by tapping the screen. This is what I have so far.
if ((Input.GetKey(KeyCode.UpArrow) || (Input.touchCount > 0 && Input.GetTouch(0).phase== TouchPhase.Began)) && levelCompleted == false) {
locVel=transform.InverseTransformDirection(rigidbody2D.velocity);
locVel.y = locVelY;
rigidbody2D.velocity = transform.TransformDirection(locVel);
}
This script moves the object up in the same velocity when tapped. But I want the object to move faster when tapped repeatedly. How to achieve this ? . Your help would be highly appreciated.
Thank you.
Answer by Infinite_Gamer · Apr 05, 2014 at 07:08 AM
I am newish to unity but what I would do is have a timer set to a default time and if the button/screen is clicked faster than the timer then "rigidbody.addForce(something here)" .
I hope that this helped you :D
Your answer
Follow this Question
Related Questions
Smooth movement using Rigidbody2d 3 Answers
Question regarding Ridigbody2D.velocity.magnitude 1 Answer
Long tap on the screen 2 Answers
Need help with my movement script.. :( 1 Answer
Ball moving in a tube 0 Answers