iminib3d bug with moving parented entity

BlitzMax Forums/MiniB3D Module/iminib3d bug with moving parented entity

jhocking(Posted 2010) [#1]
I'm running into a really frustrating problem with moving the player after parenting them to a moving platform. I'm not sure this is a bug with iminib3d because I haven't isolated down what exactly causes the issue and thus I can't reproduce it outside of my game's code, but I've been working for almost two days straight to figure out what mistake I made and I can't see any yet.

Basically, I just started implementing moving platforms in my game, and so I put in code to parent the player to a platform when they collide with one. I use TranslateEntity every frame to move the player down with gravity. What's happening is, well, let me show you the console output from a debug statement I put in.

Here's a report of the player's position every frame (the issue is visible in the last number, the Z coordinate) using local coordinates. I've copy-pasted the part when the player walks onto platform:


To help clarify what's going on, here's that same information but reporting global coordinates:


So what's happening is that the player is around 74 units on the Z axis when they walk up to the platform. Then they are parented to the platform and positioned correctly for one frame (-1.8 local to the platform is about 74 in global coordinates) and then in the next frame they are catapulted out to 151 (that's the player's position in global coordinates plus the platform's position.)

Now after seeing this result I figured "oh well then I can work around this bug by saving the player's position right after parenting and then force them to that position next frame." Here's the result after doing that (switching back to local coordinates):


doh! That time it got the position correct for 2 frames instead of 1, but after that it still catapulted the character away, and not just on the Z axis this time.



Does anyone have any idea what could be going on here? Again, I'm not sure this is a bug in iminib3d, I just suspect that. I do know the problem isn't as simple as a bug moving a parented entity, because I've tried parenting cubes to the player to test and those move around no problem.

I also guessed that maybe the problem was doing collision detection against a parent object (ie. detecting the player colliding with the platform after parenting the player to the platform) but I tried parenting the player to a pivot that moves along with the platform, rather than parented to the platform itself, but still got the positioning problem. My next troubleshooting step right now will probably be to repeat that last test, in case I just didn't do it right the first time.


jhocking(Posted 2010) [#2]
Another hypothesis occurred to me: perhaps the problem is with doing collision detection on a parented entity separate from the entity it is parented to. In other words, if a child entity has collision detection but the parent does not, that could make the child's position all screwy.

Ultimately however I didn't bother to test this hypothesis, because it occurred to me I didn't actually need to parent the player to the platform anyway, just move the player too when moving the platform every frame. This avoided any tricky positioning bugs due to parenting, and now the characters in my game ride moving platforms perfectly. yay