Flicking Objects
Posted: Mon Mar 26, 2012 8:22 pm
I trying to create physics that simulate hitting a ball by "swiping" or "flicking" it with the mouse/touch. Right now how I am approaching this is by creating a body (not added to the space) that is locked onto the mouses position and I update its position every loop. Then I have a joint connecting the "mouse body" to another "touch body" that is actually added to the space (this way it updates its velocities and performs collisions and such).
The problem I am having is that if you swipe to fast, there is no collision with the ball, or the ball barely moves (I'm guessing because there is only a tiny impulse for one step so it is not noticeable). What can I do to increase performance on this and make sure that no swipes go through the ball? Is this the best way to approach it? I have tried using a smaller step (currently 1/60.0f) and also tried increasing iterations (currently at 10). Is there anything else I should try or a better method such as raycasting that I could use to make this sort of physics?
Also I am currently removing the body after the collision seperate function because if I don't sometimes I swipe through the ball and then the ball runs into my swipe and bounces backwards. Any better way than removing the touch completely to avoid this?
Thank you!
The problem I am having is that if you swipe to fast, there is no collision with the ball, or the ball barely moves (I'm guessing because there is only a tiny impulse for one step so it is not noticeable). What can I do to increase performance on this and make sure that no swipes go through the ball? Is this the best way to approach it? I have tried using a smaller step (currently 1/60.0f) and also tried increasing iterations (currently at 10). Is there anything else I should try or a better method such as raycasting that I could use to make this sort of physics?
Also I am currently removing the body after the collision seperate function because if I don't sometimes I swipe through the ball and then the ball runs into my swipe and bounces backwards. Any better way than removing the touch completely to avoid this?
Thank you!