I’m developping a VR game with HTC Vive, and i’m starting by making a ball interact with a racket.
The ball is a Sphere (radius 0.1) with a rigidbody.
The Racket is a cube, in a rectangular shape : x:0.2 y:0.2 z:0.03
The ball interact with the racket quite well at slow speed, but when I move my racket faster, it goes through…
I tried to tweek some physics value :
Fixed Timestep to 0.01 (1/90 for the Vive)
Solver Iteration : from 6 to a lot a values, even 100 (just for test purpose), it helps a little but not too much.
I also tried to add the DontGoThroughThings scripts but it does not help
I changed the collision detection to “Continious Dynamic” for both and try changing Interpolate to the interpolate and extrapolate…
Nothing will do, How should I achieve this?
I do not want to code that (should I?), because it has to feel very realistic (VR…) when my ball is on my racket. I assume Unity should be able to handle that?
The post is old but If somebody will stuck on this:
The only one way to make it working nice is to make collision detection and changing velocity of the ball without rigidbody on the racket.
So, how i made it:
create empty prefab (name it RacketController for example) and give him box collider with a trigger and rigidbody with cinematic, like a child of this object i add Racket with only box collider. (I need parent cose i must to change the child visible or not for type of controller tracker or joystick)
Add a script to RacketController that change Rigidbody position (important that it is rigidbody) to position of my right controller
Add checking velocity of the rigidbody and saving it to variable
Create a ball with a rigidbody and sphere collider
Create a script and add it to the ball where i cheeking the collision and use such formula
direction = Vector3.Reflect(lastFrameVelocity.normalized, collision.contacts.normal);
this.GetComponent().velocity = direction * speed;
where lastFrameVelocity is the velocity of the ball on starting collision and collision is the object that ball is touching. And after i just add new velocity to the object.
And i the object name is Racket for example i get the velocity from RacketController and multiply it with the ball velocity.
float addForce = RacketController.GetComponent<TrackerFollow>().RacketVelocity.magnitude;
speed += addForce;
And i remove physics material from the ball to make all work done by script.
The final result not best but now the ball not crossing the object through. There need some working with a script to make force on ball more realistic but it work.
Hope for someone this post will be useful. And this is result on video:
The video link does not work anymore. Can you please post again? I am wondering how you check the velocity of a Kinematic Rigidbody in step 3 above. Do you calculate it based on transform.position?