Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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.

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 endless runner game Camera and Player are static or not 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

Best way to go about randomly creating levels? 1 Answer

so how can I place the randomly generated obstacles and coins along the up and down hill of the ground am driving on thank you 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges