Child entity disappearing from dynamic rigid body

I am implementing a roaming entity which also runs away from the player when they get too close/shoot a bullet near them. I am using an entity with a dynamic rigid body to simulate the movement/physics, along with a child entity which is only a mesh which will be what the player sees. This mesh is also the only part of the entity which is rotated.

Sometimes, however, the child entity disappears from view even though when I check the position of it, it is at the same position as the parent entity. It seems to twitch around the map for a few frames before disappearing completely. I think it is an issue with the way I am rotating the mesh, as when I get rid of the mesh rotation lines, the issue goes away.

this.graphicsContainer.rotate(0,Math.pow(angle,dt*1e3) ,0);

Here is the scene

The angle doesn’t look right. Why do you pow it? Any angle over 90 will result in over 1000+ degrees rotation on Y axis, which doesn’t make sense. As a start, you could clamp it to min/max, perhaps.

if dt is larger, dt*1e3 can possibly become pretty large number. When you then use it as a power exponent, the result can be so large if won’t fit in the number and give you Inf. From then on, the math goes wrong.

oh I was doing it to try and separate it from the fps, I may have done it wrong :sweat_smile:

It appears that this may have been the issue, I changed it to just be the angle and it seems to be acting fine. How would I make the rotation frame rate independent? I want it to rotate 1 or 3 degrees per frame at 60 fps.