- Home /
Fast Tapping Objects.
Hello, i am working on a game in which the objects are falling at a high speed and i tap the objects with input.touches with raycasting and destroy them. the objects have 2d colliders. the problem is that raycasting works on normal speed but at high speed the touch is not detected. i have searched everywhere and thought it was touch problem but then i have come to a conclusion that the physics frame rate is not fast enough for touch to detect colliders. i tweaked with the timestep in the time manager, but it still doesn't help me enough.
Have you tried changing the interpolate settings on the rigidbodys?
$$anonymous$$ovement can be a bit quick and jerky from one FixedUpdate() to the next, but this will smooth the movement across the frames that occur in between, and may help sort your problem as a result...
Ah, I was thinking maybe the raycast was missing the collider in between FixedUpdate()'s...
Do you handle the touch in Update(), input is normally frame rate dependent, even though you have to run the physics in FixedUpdate()...?
$$anonymous$$ust admit I'm at a loss too, I will get back if I think of anything useful... :(
Do you do your raycast in Update()? Just though you could maybe set a touched bool to true(in Update()) then pick this up and raycast in FixedUpdate() (when it is true), if you get what I mean...?
$$anonymous$$ight be worth a quick try...
Answer by vptb · Nov 20, 2014 at 06:15 PM
Are you trying to do something like the mobile game "Piano Tiles" (http://www.youtube.com/watch?v=HR8PNyTPpMo#t=55)?
Some time ago I tried to replicate that game and I found the exact same problem that you're facing, I tried several solutions and the best one that worked very good was to move the colliders, let me explain better.
In that game the objects (and their colliders) are moving down, and later in a play they will move really fast, what happens in Unity is that the touch is registered, but when you it tests if it hits a collider, the collider isn't there any more. So the solution I found was to move the center of the colliders upwards in relation to their speed. So basically in a low speed they will be centered on the object, but as the speed increases they start to move up, making it so that when the device detects the touch, it will still hit the collider.
Your game might be a little different, but you can try the same approach.