playMaker

Author Topic: Objects going through each other at high speed (bat vs ball)  (Read 8694 times)

Odd_But_Awesome

  • Playmaker Newbie
  • *
  • Posts: 22
    • Odd but Awesome
Objects going through each other at high speed (bat vs ball)
« on: October 03, 2018, 10:13:53 AM »
Hi all,

This seems to be a common issue and I have Googled many pages and while some have improved my situation (dontgothroughthings script) it is still an issue on my Rift.

Balloons drop and I swing the paddle - if at a moderate speed most balloons behave as expected and get tapped away. If I flick the controller to swing quickly the balloon goes through the paddle to varying degrees dependant on swing speed.


I have a paddle attached to my controller - I have tried fixed hinge, VRTK auto grab, direct parenting and get/set POS/ROT. Paddle has box collider and rigidbody as per image Paddle.jpg.

Balloon has capsule (tried sphere and same result) collider and rigidbody as per image Balloon.jpg.

Also tried with a basic Unity primitive box for the paddle and sphere of the ball - same result = pass through at high swing speed.

My Timestep is set to .01111.


I have tried very large (>2x mesh size) colliders and various combinations of gravity, kinematic etc.

I have also tested this with the VRTK legacy example of 0026 autograb sword scene and the Unity box primitive still goes through Unity sphere primitive.



What is the best way to detect hits of 2 rapidly moving objects and make them react like a bat vs ball would. I would think this is a common thing some developers would have run into in the past.

I have very limited coding knowledge and have relied on Playmaker for almost all my previous games construction. So I guess a solution using PM would be awesome, unless someone can point me to a script or plug in which will do the job.


Thank you for taking the time to read.
JG
Check out my games & VR Cardboard titles at https://oddbutawesome.weebly.com/apps-new.html

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15537
  • Official Playmaker Support
Re: Objects going through each other at high speed (bat vs ball)
« Reply #1 on: October 04, 2018, 03:48:48 AM »
Hi,

 unfortunatly, there is nothing inside PlayMaker that can address this, this is puerly a Unity physics setup issue I am afraid.

Have you tried to do raycasting every frame? if you check the signed distance between the ball and the bat, this will allow you to act when the distance changes sign.

 Bye,

 Jean

Odd_But_Awesome

  • Playmaker Newbie
  • *
  • Posts: 22
    • Odd but Awesome
Re: Objects going through each other at high speed (bat vs ball)
« Reply #2 on: October 04, 2018, 05:19:20 AM »
Thank you for replying Jean.

I feared as much. I haven't tried raycasting every frame. I thought that the dontgothroughthings script did something similar. I may have to investigate more.

Thanks again.
Check out my games & VR Cardboard titles at https://oddbutawesome.weebly.com/apps-new.html

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7623
    • jinxtergames
Re: Objects going through each other at high speed (bat vs ball)
« Reply #3 on: October 04, 2018, 08:38:19 AM »
Hi.
Do you have a link to this "dontgothroughthings"

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Objects going through each other at high speed (bat vs ball)
« Reply #4 on: October 04, 2018, 08:50:46 AM »
Check Rigidbody set to continuous. Or, check this:

Quote
From my testing what I can tell here is this (and I've verified in a demo scene)
Let's take several cases.
1. A projectile (discrete) travelling fast will go through a static wall (simply a box collider OR a mesh collider. Its not a dynamic object as there's no rigidbody.
To solve, we add continuous to the projectile - voila. Problem solved, no matter the speed.

Now let's take it a step further and add a dynamic object to the mix. In front of our static (ie no rigidbody, dont actually have to mark as static in 5.x) wall that our projectile hits we dangle a sphere on some hinge joints (we could prob also just drop a sphere there and on its rigidbody turn off gravity - but the dangling ball looks cooler)

Even though our projectile is set to continuous, it will go right through the dangling ball. We must set the dangling ball OR the projectile to continuous dynamic. Both have to be at least continuous and one continuous dynamic. The mesh collider here doesn't matter.

Bottom line - it works as I've described with mesh colliders or a box collider. My guess mesh colliders are mentioned as they are the most complex type of collider, but from what I can see this applies to all colliders (3d - haven't done any 2d testing here)

found here:
https://forum.unity.com/threads/collision-detection-discrete-vs-continuous-vs-continuous-dynamic.291818/
« Last Edit: October 04, 2018, 08:53:35 AM by Thore »

Odd_But_Awesome

  • Playmaker Newbie
  • *
  • Posts: 22
    • Odd but Awesome
Check out my games & VR Cardboard titles at https://oddbutawesome.weebly.com/apps-new.html

Odd_But_Awesome

  • Playmaker Newbie
  • *
  • Posts: 22
    • Odd but Awesome
Re: Objects going through each other at high speed (bat vs ball)
« Reply #6 on: October 04, 2018, 10:54:06 AM »
Thank you @Thore,

I will check it out. I have made some progress I guess. I have enlarged the paddles a bit more (maybe my game can lean towards the ridiculous:)).

Also I am pretty sure this will impact performance but I haven't got to the optimisation stage yet - I read adjusting Project Settings\Physics - Default Solver Iterations sometimes help. Default 6 - I am currently testing at 20 without visible loss of FPS. I still need to get Graphy or something similar running to be more exact. 

It appears (going by feel alone) I am getting a ~50% improvement in the number of balloons that don't go through and/or I can swing just a little bit faster without pass through. But still there are escapees.

Check out my games & VR Cardboard titles at https://oddbutawesome.weebly.com/apps-new.html