Rigidbodies Teleporting Unexpectedly

So, I’m not exactly sure when this issue started, but I think it was when I upgraded the unity editor. I’m currently using 6000.0.23f1.

The rigidbodies in question are all moved by addRelativeForce and have been working correctly until recently.

What is happening is that sometimes an enemy or enemy missile teleports a short distance (a few to hundreds of meters) from where they are supposed to be. I can identify no reason for them to do so. After they teleport, they behave normally and seem to retain their previous momentum, direction, etc. Most of the ships around the one or two that glitch act perfectly normal.

Some of the enemy ships (spaceships) will sometimes move and maneuver many times faster than usual. Not all of the ships do it and it doesn’t happen often. It’s like the forces are multiplied by 100’s.

Recently I have been working on colliders to determine when the player was in detection range as opposed to checking the distance. I’m not really sure how this would affect the physics behavior in the way I’m seeing as they don’t seem to be colliding as much as just disappearing and reappearing. Also the colliders are on layers that are set to collide with a trigger layer.

My question is basically where and how do I start looking for the issue? I can’t isolate any events that would trigger the problem. I can’t recreate it at all, it just happens. It does seem like a bug, but I’m at a loss as to how I verify this.

Sooo, I found out what the problem was. I was using a small collider on the targeting system of the enemy ships that allowed the enemies to lead the player while shooting at them.

This collider is moved to a location in front of the player calculated by speed, trajectory, etc. Then when the enemy ship had completed it’s turn to face and detect the collider with a raycast it knew to fire.

For some reason this collider was being used in physics calculations when it wasn’t before. I thought maybe I had unchecked the trigger box, but then to fix the problem I checked the trigger box and also had to check the Queries hit triggers in the Physics settings, which I know I didn’t uncheck.

So basically the ship was rotating on some center point between the ship itself and it’s targeting collider making it appear to teleport. Changing the targeting collider to a trigger collider fixed the problem.

1 Like