I have a body of which I want to change the size and position. The idea is that its height shrinks, but it shifts down so that it is still resting on the static object below, without having to fall down. I know that it's desirable to never manually set the position for a body that is otherwise handled by the physics engine, but as far as I know, there is no other way.
When I do so while the body has no velocity (i.e., it is currently resting), it pops up, as if reacting to a collision between the body's NEW position / OLD size and the static object upon which it is resting. From what I can tell, this consistently happens three frames later.
When I do so while the body HAS velocity (i.e., it is moving horizontally), more often than not it doesn't pop up.
There is a layer of abstraction between my code and Bullet, and there's some other hoojiggery specific to the project, but the functions seen accessed here do exactly what they say and only what they say. The body's size and position are changed. Nothing else.
//gets the current position of the body
Vector4 newPos = getOwner()->getBody()->getPosition();
//scales the height of the velocity by 0.5, leaving the width and length as they were
//calculates the new position where the body is shifted down so that it is still resting on the body below
//sets the new position
I am not an expert on Bullet, by any means. My team member set all of this up. I only use it when I need to. Unfortunately, he isn't sure what the problem is, either. I feel like there is something simple I am missing. Does Bullet not take the new size into account until after
it next tests for collisions? So, in other words, the body is shifted down immediately, but the scaling is delayed?
Any help would be appreciated!