0
\$\begingroup\$

I want a thrown disc to travel along the same height, even after collisions. The problem is, there's an edge case that I'm not sure how to deal with.

The lowest-tech solution would probably be to quickly interpolate the rotation of the disc so that it's flat, and also interpolate its height so that it never collides with another object in a way that would impact its height, but that might be a bit heavy-handed. I worry that it would look really bad if you're holding the disc at an angle when releasing it for a throw, and it just suddenly "swooshes" flat mid-flight. Would that seem janky?

If I don't do that, and I simply retain the disc's rotation as it flies along its path, then it might collide with an object's edge in a way where the correct bounce angle would send it upwards or downwards, which I don't want. But if I simply hard-code the y velocity to 0, then in those instances, the lateral velocity becomes very low. Should I just check for a "minimum" speed, and increase it to that if it falls below that? Because the issue is that in the case where it bounces upward, there's a good chance that the correct bounce angle, if the y velocity is ignored, results in the disc continuing in the same direction rather than bouncing.

So I'm honestly leaning towards extending the collision boxes for these objects really far above and below where the disc could possibly be thrown, that way regardless of its orientation, it would always be the side of a cylinder colliding either with the side of a box or one of its vertical edges, and the velocity change should thus (hopefully) always look like it makes sense.

\$\endgroup\$
  • \$\begingroup\$ I find it unclear what you mean by "travel along the same height". Based on the virtual-reality tag I assume this is 3D ... can you not throw the disk up or down? In that case the height is already changing before any collisions, so what do you expect after a collision? Could you include some diagrams? \$\endgroup\$ – rcorre Dec 5 '19 at 22:46
  • \$\begingroup\$ I'm restricting height changes on a throw because you wouldn't want the height to change after throwing, basically. I may alter that to allow free throws if you "whiff." Imagine something like this, in 3D: youtube.com/watch?v=F1I0lzM_UZI You wouldn't want to throw above or below those bubbles. But unless I extend the hitbox, if your throw starts at a height above or below them, or the disc is rotated a certain way, it might make sense for it to bounce above or below. So I'm not sure how to handle it well. \$\endgroup\$ – Roderick Dec 5 '19 at 23:29
  • \$\begingroup\$ I'm having trouble imagining that in 3D. In 3D, you can aim up/down, in which case the disk will have a y velocity, and the height will change while flying. Are you restricting the player to throw the disk in only a specific plane? \$\endgroup\$ – rcorre Dec 6 '19 at 0:17
  • \$\begingroup\$ For now, yes. That video, in 3D, would let you throw up, down, left, and right, but also in and out. A throw aimed in or out would miss. \$\endgroup\$ – Roderick Dec 6 '19 at 1:45
1
\$\begingroup\$

It sounds like what you want can be achieved with the various axis lock settings in RigidBody:

enter image description here

Here I've locked linear_y so the disc cannot move up or down, and I've locked all angular movement, so it cannot rotate at all. Here's a demo:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ In my case, the disc is a kinematic body, because I need to control how it moves and bounces, so there is no axis lock feature available. For example, I may alter the bounce angle and speed on impact. \$\endgroup\$ – Roderick Dec 6 '19 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.