I have made a level of a game where there are a square, that is the protagonist, a wood square to cross spikes, the spikes, obviously, a platform and a background, but when I want to try the game many times it load invisible things and I can’t move correctly the protagonist. I think that it’s important to say that i have used the physics automatisim.
What can I do to make it run correctly?
post-data:sorry for my poor english
Can you give us your project to see what happens.
there is the game juego.gdg (19.8 KB)
It’s will be more easy for us to test if you also send the images you used.
i think that is this
packaged_game.zip (265 KB)
I take a look at your project and realizes that everything you said is true, every time the level reloads there are “phantom” objects obstructing the way.
I check the object instances in the debugger window and found the level always keeps the instances of objects with physics automatism from previous instances of the loaded level due to some kind of bug, these phantom instances interact with another objects with physics automatism even when they are not visible.
First I tried changing the scene to another completely different scene instead of reload the same scene from itself (I make a press-space-to-continue screen) but it don’t succeed preventing the “phantom” objects.
So, finally I created an object group referencing all the objects affected by the physics automatism and delete it (deleting with it all the objects with physics automatism) every time the level scene is changed, this way the “phantom” objects are eliminated.
I also change the timed event that change the camera focus from the goal object to the player object after a second, for an algorithm that smoothly moves the camera focus from the goal object to the player object and after that allows the player to control the player object.
This algorithm also prevents the camera from moving any further the player object position by checking the current distance between the camera and the player object, it can be adapted to use it with sprites that moves at high speeds and have to collisionate with other objects (for example bullets, for preventing “missed” targets).
Here is the “fixed” project. I traduce the name of the objects from spanish to english because I want everyone could take advantage on this example, but anyways, the project is heavily commented in english and spanish So, hope it helps:
moving_camera-physics_automatism_and_reloading_levels.zip (14.5 KB)
Strange bug indeed. 4ian or other gd developer will have to take a look.
I dindn’t know how to do that move of the camera so thank you too