Hi, guys!
I’m working on endless runner game. I’m creating the prototype now. Game world created from some prefabs (ground parts), which were preloaded from an array. Some kind of pooling system. Whole game world creates from 3 ground parts/blocks, which sticks and moves together. All these first blocks/prefabs placed by code in one JS file, which attached to an Empty Game Object (some kind of World Inspector). Those tree blocks stick perfectly without any gaps (visible seams) between them.
When first block moves out of the screen I deactivate it and place the new one at the end of the stack. Check for deactivating the object happens in other JS file, which is connected to a prefab/block itself. And here the problem appears. Every new blocks I’ve created have a small seam/gap between him and others blocks.
Here you are some check code sample:
// If object is out of screen, than...
if ( transform.position.z <= -30 ) {
GameObject.Find("Pool Inspector").GetComponent(objectsPoolingScript).PrefabPlacement(false); // Execute the function for new prefab activation
gameObject.SetActive (false); // Deactivate the prefab, which is out of screen
transform.position.z = 0.0; // and reset its position
When I’ve checked Z position of the object I saw that my check executes not in perfect -30.0 value, but something around -30.045 value. Those value changes time to time. So, I think that this .045 is a gap problem. But I can’t understood how to fix it and why is it happen? Maybe there’s a delay between send some values from one script to another? But how to fix it?
So, maybe you, guys, will able to help me to settle it? Thanks.