Physics Objects "Bump" when restarting/switching scenes

EDIT: I put physics.stop() before the swap and now its an entirely new set of problems; sometimes physics doesn’t initiate correctly in the next room, causing all sorts of errors with the simulator.

I’m having a problem with the director class. It doesn’t produce any sort of code errors to show from the console, however it can make for some very odd effects in the game.

When I either restart a level or switch a level through director, the physics bodies seem to be (I assume) overlapping for a split second with the newly created scene, causing them to bump any others that happen to be at a position. For example, if i restart a level that has a stationary ball, or skip to a new level with a ball in the same position, the new one will be knocked slightly to either side and start rolling.

I have a hazard that pops up a “level failed” screen when your ball collides with it, and upon skipping a level, if there is a hazard in that position in the next level, the first play of that level instantly says failed. There is a similar problem with the next levels goal being in the same position.

I’ve tried deactivating certain bodies before switching levels, however it had no affect. Can anyone help me out here?

Thanks! [import]uid: 80536 topic_id: 16478 reply_id: 316478[/import]

I’ve had a similar experience. I didn’t use physics.stop() to work around it. It may not work for you (because it depends on what your screen looks like before the scene changes for this to work), but one of my work around was to make the “hazard” in the old scene invisible and move them way off screen before scene changes. [import]uid: 67217 topic_id: 16478 reply_id: 61514[/import]

I’ve tried that before with no luck. I’ll give it another go when I can though.
Edit: Alright easy fix; Creating a go-between “loading level” empty room that it goes to beforehand. [import]uid: 80536 topic_id: 16478 reply_id: 61703[/import]

That sounds cool, Shady Guy. So, how does go-between “loadingLevel” work?

When the screen transitions from level1 to level2, you change the scene from level1 to loadingLevel, and then automatically change scene again to level2?

Do you use timer to load and unload loadingLevel? I’d love to know how you implemented it. [import]uid: 67217 topic_id: 16478 reply_id: 61960[/import]

My loadlevel.lua is set up so it can be used universally by all the levels - before the director switches the scene, I set a global variable to the level that will be loaded next. That’s either the current level, or the next level, depending if the context is a restart, victory, or skip. It goes to loadlevel, which is empty except for a loading level screen. A timer is set to a second or so just for tidiness, although technically a millisecond change should work as well, then it changes to the level indicated by the variable.
The variable in my case is just set to the name of the levels lua file, so director can easily access that without any fiddling. [import]uid: 80536 topic_id: 16478 reply_id: 62006[/import]

That sounds really good! [import]uid: 67217 topic_id: 16478 reply_id: 62020[/import]