- Home /
iPhone - Collision sometimes not detected when swiping too fast
Hi guys!
I'm making a slicing game using Raycast but when I swipe across the object too fast, the collision sometimes didn't take place. I couldn't find any definite solution to this. I applied a Trail Renderer to show the slicing effect and the effect showed clearly that the swiping takes place across the object. Is it because of the collision method? I tried changing the collision detection in the object Rigidbody properties to Discrete, Continuous, and Continuous Dynamic but there seems to be no difference. I appreciate any tips and advice related to this problem.
Another thing, is it normal for the game to run on 30 frame per second on iPad 2?
Thanks in advance =)
Answer by reptilebeats · Feb 17, 2012 at 02:40 PM
If ur only using oncollision enter try using stay instead, enter can be a bit finiky for some things, if not try all 3 enter exit stay. Also are u just testing on emulater or actually putting it on ur phone. U got to take in consideration of the lag time
Sorry for late reply. I'm not using OnCollisionEnter, I'm using RaycastHit because my game is 2D and it's just shooting objects with a tap. Looked for solutions and it seems RaycastHit is the best option for my case. I don't think the game lag at all. I tried spawning 20 objects at once and it is still fine. The fps is 30 and I feel it's a bit slow because I'm pretty sure 60 fps is the best number for a game.
Answer by stepan-stulov · Jun 13, 2014 at 10:41 AM
If you swipe too quickly, there is always a possibility that previous touch position is outside and in front of your gameobject and the current touch position is also outside but already behind your game object. Simply becayse the touch screen works descretely and cannot provide position data more frequently. I'm not sure if the described routine with colliders include continuous calculation, something tells me it rather doesn't.
What you have to do if you want a really nice smooth experience on very fast moves is to test whether the segment betwee the two most recent touch positions intersects the collider's/gameobject's screen projection.
It's similar to how collision prediction in physics works in case something flies to fast and in the current update is far before a wall, and in the next update is far after. Yet the hit is detected as they check whether the line between the two positions intersects the wall.
Your answer
Follow this Question
Related Questions
iPhone touch raycasting 1 Answer
Unity iPhone: AddForce to Object after Touch 0 Answers
Input.GetAxis("Vertical") on touch devices. 2 Answers
How can I detect touch on anroid or iphone 2 Answers
Touch collision detection with a sprite 0 Answers