Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by SnaiperoG · Jul 26, 2016 at 04:45 PM · bugrunnerinfinite runner

Please help, Unity bugs or not?

I trying to make infinite runner. Ive made a plane which 2x2 and a script which fill place. It works like fill place 3x25 and start move -x coordinate. if some child has x: -2 coord it will destoy, if childcount < 3*25 it instantiate a 3 new. But here somehow little holes alt text

Ive change logic of script, now childs doesnt destroying they just change them position to some coords and move back when childcount < 3*25 but it still buging

I cant find where my mistake do. Havent attach for the code so here is. P.s. increase gamespeed increase holes like that.

 using UnityEngine;
 using System.Collections;
 
 public class LevelScript : MonoBehaviour {
 
     public float widht_field;
     public int game_field_lenght;
     private float NextPosX;
     public float gamespeed;
     private GameObject LevelEmpty;
     private GameObject TmpObj;
     private float ZCoord;
     private GameObject CollectedFields;
 
     // Use this for initialization
     void Start () {
         ZCoord = -widht_field;
         LevelEmpty = GameObject.Find("LevelEmpty");
         GameObject Fields = new GameObject("Fields");
         CollectedFields = GameObject.Find("Fields");
 
         SpawnObjects();
 
         FillScene();
         NextPosX -= widht_field;
    
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     void FixedUpdate()
     {
         Debug.Log(Time.deltaTime);
         LevelEmpty.transform.position = new Vector3(LevelEmpty.transform.position.x-(gamespeed*Time.deltaTime),0,0);
         CollectedFields.transform.position = new Vector3(200,0,0);
         int count = LevelEmpty.transform.childCount - 1;
         for (int i = 0; i < count; i++)
         {
             if (LevelEmpty.transform.GetChild(i).transform.position.x < -2)
             {
                 LevelEmpty.transform.GetChild(i).transform.position = CollectedFields.transform.position;
                 LevelEmpty.transform.GetChild(i).transform.parent = CollectedFields.transform;
                 i--;
                 count--;
 
 
             }
         }
         //foreach (Transform field in LevelEmpty.transform)
         //{
         //    if (field.position.x<-2.0F)
         //    {
         //        field.gameObject.transform.position = CollectedFields.transform.position;
         //        field.gameObject.transform.parent = CollectedFields.transform;
 
         //    }
         //}
 
         for (int i = 0; i < 3; i++)
         {
             if (LevelEmpty.transform.GetChild(i).transform.position.x < -2.0F)
             {
                 LevelEmpty.transform.GetChild(i).transform.position = CollectedFields.transform.position;
                 LevelEmpty.transform.GetChild(i).transform.parent = CollectedFields.transform;
 
             }
         }
         if (LevelEmpty.transform.childCount < (game_field_lenght) * 3)
         {
             SpawnField();
         }
     }
     void FillScene()
     {
         for (int i = 0; i <= (game_field_lenght)-1; i++)
         {
             SpawnField();
             NextPosX+=widht_field;
         }
 
     }
     void SpawnField()
     {
         for (int i = 0; i < 3; i++)
         {
             TmpObj = CollectedFields.transform.GetChild(0).gameObject;
             TmpObj.transform.parent = LevelEmpty.transform;
             TmpObj.transform.position = new Vector3(NextPosX, 0, ZCoord);
             ZCoord += widht_field;
         }
         ZCoord = -widht_field;
     }
     void SpawnObjects()
     {
         for (int i = 0; i < (game_field_lenght)*3; i++)
         {
             GameObject tmp1 = Instantiate(Resources.Load("tank_field"), new Vector3(NextPosX, 0, 0), Quaternion.Euler(270, 0, 0)) as GameObject;
             tmp1.transform.parent = CollectedFields.transform;
             tmp1.transform.position = Vector3.zero;
         }
         CollectedFields.transform.position = new Vector3(-200,0,0);
     }
 }
 

alt text

bug1.png (120.2 kB)
bug.png (90.5 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jessespike · Jul 26, 2016 at 06:58 PM

It's likely a bug in your code. Since you've noticed that increasing gamespeed makes the problem worse, I'd look over that. I would bet it happens because the position is multiplied with deltaTime in a FixedUpdate, that just seems incorrect.

Comment
Add comment · Show 2 · Share
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
avatar image SnaiperoG · Jul 27, 2016 at 05:02 PM 0
Share

Ive wrote this code like in tutorial. Bad part of runner tutorials, that no explanation in it. Can you tell me why its wrong and what need to do to fix it?

avatar image SnaiperoG · Jul 28, 2016 at 05:00 PM 0
Share

Even if i trying to multiply position not with deltaTime. With float 0.2 for example, my field generation still have those holes.

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

66 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Missing Shadows on Some Objects 0 Answers

Particle Collision Bug. 1 Answer

Unity Keeps Destroying My Projects. Please help! (Urgent) 1 Answer

Player keeps bumping when walking over to another sprite 1 Answer

Light Shadow problem 1 Answer


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