cancel
Showing results for 
Search instead for 
Did you mean: 

problems with fast moving object collision in unity (table tennis racket vs ball)

ProTT_VR
Honored Guest
hey 🙂

i m building a table tennis vr game right now and ran into collision problems...

if i let the ball drop on the racket or move slowly all is fine but when i try 2 hit hard the racket goes right through the ball...

tried 2 find for 2 weeks now the solution 2 my problem online,youtube,unity forums,udacity (taking the vr dev course ) forums but no1 could help me,so i thought ok maybe at oculus some1 had and solved the same problem,maybe its vr related...

any ideas?any1 had the same problem and knows how 2 solve it?
7 REPLIES 7

Claytonious
Explorer
You should change your ball's collision detection mode. You can do that in its inspector or via script. See https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html.

ProTT_VR
Honored Guest
@imperativity hey 🙂

this is my capstone project at udacity vr dev i started in june...
right now i m using steamVR and the rift 2 complete this project in 1 week but then i wanna perfect it and put it also on oculus store, so i will build in also the OVR sdk... y? will it make a difference of how collisions behave? or r u asking coz u can support only projects/devs who develope for oculus store?

@Claytonious hey 🙂

i wish it was that easy...

no conventional solutions work,and from what i heard there might b no other solution than creating a physics engine from scratch 2 deal with all the real-life physics i need 2 b able 2 create a 1:1 real-life simulation coz unity's physics engine might not b able 2 deliver...

i just hope there is an easier way,searched everywhere,no1 could help me,so i posted here coz i will develop this game for oculus and i thought it might b a VR related problem other devs here might have run into and solved...coz when i set up a test scene and trigger it by mouse click there r no problems no matter how fast the ball is,it just happens when moving the racket via controllers in VR...

JoeTheHobo
Honored Guest
I'm two years late but I'm having the same exact problem. Did you ever find a way to fix it or did you just end up making your own physics engine?

LoneWolfDev
Honored Guest
From my understanding you need to use ray-tracing instead of relying on the physics engine to detect when objects intersect. The physics interaction is too temporary for it to detect properly. 

Try to set collision detection on your Rigidbody to continuous dynamic.

If that's not working try to send a ray from the racket and use the hit normal to calculate the direction to send the ball away in.

Hope that puts you onto another direction to try.

m4ng4
Honored Guest

I bet you are using wrong movement type on the "ball" there are 2 kategories to calculate movement where one checks collision after each frame and one checks the collision between frames.

I did this e few years back and they both function visually the same but one of them can never pass through collider.

maybe i can help you more when i get home.

Edit* if thats not the case, then you chould change movement typ on the racket.

Grirvaldr
Honored Guest
Bruh, here's my recommendation:

Under Edit -> Preferences -> Time you will find a Fixed Timestep for calculating Physics. The easy solution is to set the collision detection to Continuous Dynamic and set that Fixed Timestep to like 0.01. BE CAREFUL WHEN YOU DO THIS! This can drastically impact the performance of your game if you load to much into your physics calculations (e.g. calling things on Fixed Update).

If that doesn't work, use Physics.Raycast or Vector3.Distance to constantly check the Distance between the objects and if it's within the threshold, run your logic.

JeffNik
MVP
MVP
I had this same issue with a table tennis game I was playing around with. I got it working after learning that you have to change the collision type to 'continuous' on both the ball AND the racket/paddle.