NJL64 I'm not sure how setting velocity to 0 fixes the issue or how to implement that, where to put it, or who's velocity. Sorry, I'm just kind of confused.
Set body.velocity
to zero. Since body.velocity
is a vector, you need to set it to zero vector value as @kuligs2 suggested, not to scalar 0
value. If you're in 2D it needs to be Vector2(0, 0)
or Vector2.ZERO
. Once you have that sorted out, assign the container's global_position
to body.global_position
. Eliminate all other code that messes with body's velocity or position (global or local).
Doing the above should result in enemy being glued to the position of the container. This is a simplified version of what you ultimately want to achieve but in coding we often first implement a simpler version of the solution (sorta like a rough sketch), make sure that it works properly, and then proceed to gradually upgrade it into more finessed versions.
So first do the simple gluing, make sure that it works and that you understand how and why it works.