Generating platforms in falling Ball Game

Updated on April 2, 2018 in Unity
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
4 on April 2, 2018

Hello Everybody, I want to ask you please about instantiating or generating platforms in a falling ball game like Sky Ball, I have struggled for about a week to find an answer but I didn’t find , my question is just how to instantiate these platforms while the ball is falling down.

PS: Excuse me for my English because I’m Francophone.

Thank You !!

  • Liked by
Reply
3 on April 2, 2018

How are you spawning the platforms now?

 

All you need to do to get the platforms to spawn at runtime, is to have the spawn function be called from some update loop or coroutine.

 

A very basic example would be something like this:

float timer = 0f;
float spawnDelay = 1f;
private void Update()
{
     timer += Time.deltaTime;
     if(timer >= spawnDelay)
     {
          timer = 0f
          SpawnRandomPlatform();
     }
}
on April 2, 2018

Thank You for your answer , I want to know if this function can spawn the platform even while the player is falling down or moving up in a 3D Game ? if just this function can be used like the case in the mentioned Game ?

Thank You very much for the answer.

on April 2, 2018

Yes, of course. The movement or position of the player doesn’t affect if a method will or will not fire.

 

Unless you want it to, but Update loops, and Main methods will always happen by default.

 

on April 2, 2018

Okey ! Thank You very Much for your answer !

Show more replies
  • Liked by
Reply
Cancel