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 /
avatar image
0
Question by nilserlingh · Feb 08, 2019 at 11:44 PM · programmingplatformerendless runner

Spawn endless platforms help

I'm trying to spawn endless platforms inside jumping distance of the player, and them make them spawn at the same distance away from each other. Anyone know how that could work from this? Right now the distance between the platforms grows everytime a platform spawns. The distance should stay the same every round. Need help with making the plaform distance more stable. Any other tips would also be nice of course.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class GameController : PhysicsObject
 {
 
     Vector3 platformSpawn;
     private GameObject[] platforms;
     public GameObject platformPrefab;
     private float timeSinseLastSpawned;
     public float spawnRate = 4f;
 
     public float platformMin = -1f;
     public float platformMax = 3.5f;
     public float spawnXPosition = 10f;
     private int currentPlatform = 0;
 
     public int platformPool = 5;
     private Vector2 platformsPossition = new Vector2(10f, 0f);
 
     void Start()
     {
         platforms = new GameObject[platformPool];
 
         for (int i = 0; i < platformPool; i++)
         {
             platforms[i] = (GameObject)Instantiate(platformPrefab, platformsPossition, Quaternion.identity);
         }
     }
 
     void Update()
     {
         timeSinseLastSpawned += Time.deltaTime;
 
         if(timeSinseLastSpawned >= spawnRate)
         {
             timeSinseLastSpawned = 0;
 
             float spawnYPosition = Random.Range(platformMin, platformMax);
             platforms[currentPlatform].transform.position = new Vector2(spawnXPosition, spawnYPosition);
 
             currentPlatform++;
             spawnXPosition += spawnXPosition;
 
             if (currentPlatform >= platformPool)
             {
                 currentPlatform = 0;
             }
         }
     }
 }
 

Comment
Add comment · Show 2
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 Spacejet13 · Feb 08, 2019 at 11:47 PM 0
Share

Tileable Platforms?

Part A

Part B

avatar image nilserlingh Spacejet13 · Feb 09, 2019 at 12:22 AM 0
Share

Like that, exept I want platforms for the player to jump on, ins$$anonymous$$d of purely visual elements. Also I want to have an offset between the platforms, and a certain randomness to where on the y axis it spawns. But it needs to be controlled enough to only spawn on places it can be jumped to. Will see if I can use the videoes still though, so thanks for bringing them to my attention.

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

110 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 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

Multiple Cars not working 1 Answer

Platform generation using object pooling 0 Answers

Platform Generation For Endless Runner 1 Answer

Running and Jumping problems of a 2D Endless Runner 2 Answers

Random Obstacle Placement 0 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