Make pipes restart

Hello, so currently in my project, when you die, the pipes stay how they were before you died

example

However, I want to change this so it is different every single time. How would I go about doing this?

Hello @ThePastaNebula! I don’t know how the original game was made, but maybe you can use Math.random() for this.

https://developer.playcanvas.com/en/api/pc.math.html#random

You can do it in pipe-height.js. You would need to modify it. Currently, the position of the pipes are calculated randomly when application initializes.

  1. Move the code, responsible for setting random position from initialize() method to its own method.
  2. Call the newly created method from initialize(), and also every time 'game:play' event is fired.
3 Likes