auto sync transforms helps, but not enough

I am working on a free game, you can check it out at Ace Racers SP by tsmspace (itch.io)

In this game, the player will place a racing hoop , then fly through the hoops in order with “build race” on , and the game will then track which hoop is next, and which direction the player should fly through. HOwever, , occasionally the game records the direction incorrectly. I have been assuming this is because the transforms and the physics have the builder in two different places for a given moment, resulting in the opposite side “direction” mesh (a 3d mesh with an ontrigger showing the players ship is there before contacting the racing mesh) , but I’ve made it bigger, moved it out a bit, and the behavior persists. INterestingly, there is an incredible consistency in the behavior, the rings that are flipped always flip. In a given set of placements, the same ring/s always flip. If I delete that ring, and replace it, the behavior follows to the new ring. If I move the ring, then builder through it, the behavior persists. THe only solution appears to be to move the ring AFTER using the builder to rotate it in place. If I place a ring there, but without the rest of the course hoops placed, the behavior is gone.

initially my direction check mesh was thinner and closer to the racing mesh, and in a test where I placed hoops in a line as fast as I could press the button, then flew through them in build-race in a line as fast as the ship could fly , many would be flipped, which was then fixed by increasing the size and separation of the direction check meshes, but I can move through some placements (of the same hoop) very slowly, and still the behavior will persist while actually trying to make a course I want to save.

My question is, what can be causing this?? I am not an experienced programmer but the problem doesn’t make sense for the position of the ring, because moving it around doesn’t fix it, and placing a ring in that place when I did NOT place other hoops, and then simply making a one-hoop course does work. I can find the issue, move that hoop way out of the way, builder through it, and it remains flipped. I can delete it, place it somewhere else, and then move it to location, and it still will be flipped when I builder through it BEFORE I move it. There doesn’t APPEAR to be any connection with the physics, although that’s the only thing I can imagine that could happen “accidentally”. THere are not overlapping meshes to confuse the trigger, and no conditions different between that hoop and another hoop, and even deleting the hoop and replacing it SOMEWHERE ELSE and then before moving it into place wont’ fix it. It’s as though that hoop is somehow tagged. ??? but it’s the same prefab. There’s nothing different. I can move so slowly through it with no benefit, and auto-sync transforms is on.

sorry, got it. wrong problem. I had a mesh that wouldn’t save to list.

So you know, AutoSyncTransforms is off by default for good reason; it’s meant for backwards compatibility only from a change made many, many years ago and it’s a terrible performance hog. If you’ve coded yourself into a corner where you need it then, it’s up to you, but you need to change your approach. Don’t change the position of something via a Transform then expect an immediate physics query to detect it; that’s bad practice and it’d be the only reason why you’d ever have that on.

presently here’s my situation. I am saving “racemeshes” to a list (a field inside of a ring that detects the player passing through it) , HOWEVER one mechanic of my game is “dockable weights”, which are objects that the player connects to and drives around while connected to. the weight can be a checkpoint. when I am saving the checkpoints and the objects, etc… I am comparing position in order to line up the various lists (if it needs a weight attached, which direction to move through the checkpoint, and the mesh itself) , when the objects are saved, the same object may be saved multiple times in one list, if the player will interact with that particular object multiple times in a course. In order to save the weights to the list, and have them load, I need to compare their location, which always is different if left to the player playing the game, so to save I am resetting their position. ----

I have to be honest there’s a lot I don’t know, and presently I have done SEVERAL things to fix it, and can do some testing now to see if I can turn it off. (autosync transforms), just for the saving, but I still end up with wonky behavior passing through rings and autosync transforms has made that smoother at least once.

I’m not sure I agree, or at least in terms of my issue. I parent a rigidbody to a transform without a rigidbody. I make the rigidbody kinnimatic so I would expect it to move with the parent. But it does not, whether AutoSync is on or off. I don’t see why physics is getting involved at all. What happens is that the child moves at about 30% of the parents movement.

I got round this by adding Physics.SyncTransforms() as I moved the parent.

Whether you agree or not, I wrote the feature so I know exactly what it’s there for and why it’s not advised to use it. Sure, you can use it as a workaround for other things but that’s not what it’s designed for and used sparingly won’t kill your performance but it has the potential to.

When you change a Transform, nothing else in Unity changes at all because there are no callbacks, public or internal. The above call is done automatically when the physics simulation runs.

Your issue/subject though isn’t the subject of this thread at all as it’s discussing AutoSyncTransforms, not the manual SyncTransforms. AutoSyncTransforms means SyncTransforms is called after every read operation i.e. physics queries, reading physics component position/rotation properties etc and that can tank performance!

1 Like

In my project in Unity 2019, I parent my kinnematic rigidbody to a transform. I move transform and the rigidbody moves as it should, In 2023 I do the same and the child kinnematic rigidbody moves at half the speed of the parent. I am not sure if Autosync or SyncTransforms is meant to apply to kinnematic objects (I have tried with and without both). But something weird is happening. This behaviour can be shown by just by dragging a transform in the scene view during play mode.

I have now tracked this down to the Interpolation setting. Changing this to None enables the kinnematic rigidbody to move with it’s parent. The documentation does not make any mention of kinnematic rigidbodies so I’m not sure if this is intended behaviour or not. It does though sound like AutoSync should make things work as intended.