1

I have a sphere collider on a stick and a cylinder. The cylinder has to detect a collision with the sphere collider of the stick and fire up a "OnTriggerEnter" script. Just imagine it like a drum stick hitting a drum in virtual reality.

Is there a way to avoid registering a collision on the sides of the cylinder, but only trigger on the top of the cylinder? And even without adding more protecting objects around it?

In the screenshot you see the properties of the stick and below the properties of the cylinder.

enter image description here

Obviously the green and red icons show which area is allowed to be triggered and which not.

Btw, simply using a thinner cylinder collider doesn't work in this case, because it wouldn't detect some collisions at all, when the stick goes too fast trough the thin cylinder. More about that in the comments.

Thank you.

DanielM
  • 317
  • 2
  • 11
  • why not just make the collider very thin at the top? Or you check where the collision point is – BugFinder Feb 02 '20 at 01:03
  • Good question and I will add the explanation to the question. Actually it was already tried with a thin cylinder. The problem is that I have to use trigger instead physics for certain reasons, and with a thinner cylinder collider sometimes the trigger wouldn't be detected at all, if the stick goes too fast through it. Probably because at these occasions when it didn't work, the collision was between frames i.e. between the points which the stick has been detected. Does that make sense? – DanielM Feb 02 '20 at 01:12
  • well you can change its detection method.... – BugFinder Feb 02 '20 at 01:19
  • Another problem with a too thin cylinder is, that the stick collides again from the bottom when the stick goes up again. And that is also unwanted. (remember, it is VR). Just the top has to be triggered. – DanielM Feb 02 '20 at 01:21
  • But as mentioned above you can check which direction – BugFinder Feb 02 '20 at 02:05
  • ok, so how would this work? – DanielM Feb 02 '20 at 02:10
  • You can change your stick to a rigidbody which follows the hand movement (ensuring you change the collision check to some form of continuous so it won't miss a beat). This has the bonus of actually making one "feel" (see) the collision haptically in VR. The newest SteamVR or Oculus plugins may already provide ready-made solutions for that. This approach will also solve triggering the wrong side of the drum, as the stick won't get to below it (alternatively, you can ensure that the stick velocity is in the right relation to the collider; I did that for a piano in VR and it works). – Philipp Lenssen Feb 02 '20 at 11:22

0 Answers0