-
I have some moving platforms set up as kinematic bodies. I like how simple this is, and how much control it gives me over the platform's motion. However, I'm having some trouble formulating an approach for handling dynamic obstacles; essentially, I want to avoid situations like these: You can see that the bodies have nowhere to go, so they begin to overlap. This sometimes causes them to fall through the level geometry altogether. Ideally, the mover would have pushed the dynamic bodies together, but stopped moving before causing excessive penetration among them. How can I achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
Hello, I would change the platform body to a normal dynamic body and constrain it's path with a slider constraint. You can activate the motor on the slider constraint and set a velocity target to make the platform move. Maybe you will also need to set the max force of the motor to something less than flt_max. |
Beta Was this translation helpful? Give feedback.
-
A slider constraint and your platform body is all you need. PoweredSliderConstraintTest.cpp is quite close to what you need to do. I've minimized the example, drop this inside that file:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the example, but I'm not sure I understand how this allows me to achieve combined linear and angular motion. |
Beta Was this translation helpful? Give feedback.
-
Oh sorry, I missed the angular part of your question. I assume you want the platform to follow a trajectory that contains rotation? (or do you want to have rotation and translation fully independent?). If you just want the platform to follow a curvy path I would suggest looking at PathConstraintTest.cpp (basically the idea is the same as the example above with attaching a body to Body::sFixedToWorld through a constraint, but instead of a line segment you can supply any path you want). |
Beta Was this translation helpful? Give feedback.
-
Ideally they would be independent. I'd like to build an abstraction over the constraint which will allow a mover to slide, or rotate, or both at a specified rate. |
Beta Was this translation helpful? Give feedback.
-
Ok, in that case I'd suggest using a SixDOFConstraint. Configure 1 axis (TranslationY, you can configure that to point in any direction using mAxisY1 and 2) to allow translation, configure 1 axis (RotationX, you can define that to point in any direction as long as it's perpendicular to mAxisY1/2 by setting mAxisX1 and 2) to allow rotation and keep all the other axis fixed. Give the translation and rotation motors and set the velocity of those motors to drive them. SixDOFConstraintTest has examples and it has a 'Test Settings' menu that allows you to play around with limits. Note that it is also possible to e.g. unlock the TranslationZ channel if you want your object to move in a plane rather than on a straight line (you'd need a 3rd motor as well then to drive it). If the translation and rotation axis are not perpendicular then it starts to get complicated, so I'm hoping you don't need that... |
Beta Was this translation helpful? Give feedback.
-
I see. Now that you've explained the available options, I think I need to reexamine the problem. I'll mull this over for a while, and then see what I can hack together. Thank you very much for your time. |
Beta Was this translation helpful? Give feedback.
Ok, in that case I'd suggest using a SixDOFConstraint. Configure 1 axis (TranslationY, you can configure that to point in any direction using mAxisY1 and 2) to allow translation, configure 1 axis (RotationX, you can define that to point in any direction as long as it's perpendicular to mAxisY1/2 by setting mAxisX1 and 2) to allow rotation and keep all the other axis fixed. Give the translation and rotation motors and set the velocity of those motors to drive them. SixDOFConstraintTest has examples and it has a 'Test Settings' menu that allows you to play around with limits. Note that it is also possible to e.g. unlock the TranslationZ channel if you want your object to move in a plane rat…