• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Baskyn · May 02, 2014 at 09:44 AM · spawning problemsendless runnerinfiniteendlessgaps

Trouble spawning endless platform

I'm having trouble spawning platforms for an endless runner/faller type game. Mine is an endless faller, so I think you can imagine what I'm trying to do.

The problem I get is I always have a gap in between at least 1 of them. The gap grows a bit sometimes. If I don't have the .2f added in, the gaps are even worse. When I speed the moving up even a bit, the gaps are about half an inch thick. This is driving me crazy. I've searched all over the forums for the answer to this. I always see people saying to use += so you won't have gaps, but that is not working at all for me. Anyone have any idea what to do? Thanks!

Here is what I have right now.

Spawning script:

 using UnityEngine;
 using System.Collections;
 
 public class WallSpawnScript : MonoBehaviour {
 
     Vector3 zeroPos = new Vector3(0, 10f,0);
 
 
     public void WallSpawn()
     {
         int objToSpawn = Random.Range (1,2);
 
         switch(objToSpawn)
         {
         case 1:
             Debug.Log ("hit");
             var obj = SmartPool.Spawn ("Wall1");
             obj.transform.position = zeroPos;
             Vector3 pos1 = new Vector3(0,((obj.transform.localScale.z * -3) + .2f), 0);
             obj.transform.position += pos1;
 
 
 
             break;
 
         case 2:
             Debug.Log ("hit");
             var obj2 = SmartPool.Spawn ("Wall2");
             obj2.transform.position = zeroPos;
             Vector3 pos2 = new Vector3(0,((obj2.transform.localScale.z * -3) + .2f), 0);
             obj2.transform.position += pos2;
             break;
 
         }
 
 
     }
 
 
 
 }




Object Script:

 using UnityEngine;
 using System.Collections;
 
 public class WallScript1 : MonoBehaviour {
 
     public WallSpawnScript WallSpawnScript;
 
 
     void Update () {
 
         this.transform.Translate(0, 0, 10 * Time.deltaTime);
 
 
         if(this.transform.localPosition.y > 10)
         {
             SmartPool.Despawn(gameObject);
             WallSpawnScript.WallSpawn();
 
         }
     }
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Infinite 2d terrain generation methods 2 Answers

Random instantiation endlessly? 1 Answer

Why does this not work (Involves instantiating objects in response to a collision*) 1 Answer

Use Tree 3d Model or Tree png img on Plane? 0 Answers

How to create a "save me" feature like subway surfers .temple run, etc ? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges