Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

How to Make a Game Like Jetpack Joyride in Unity 2D – Part 2

In the second part of a three part series, you will be generating a series of endless rooms, allowing the user to fly through them.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5459-how-to-make-a-game-like-jetpack-joyride-in-unity-2d-part-2

in here is AdjustJetpack(jetPack);

@mplaczek Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi,
I hope you have been enjoying the tutorial so far!

The AdjustJetpack method takes the jetpackActive variable to determine what rate the particles should be set to.
This is done at the end of the FixedUpdate by calling:

AdjustJetpack(jetpackActive);

jetpackActive Is a Boolean, meaning it can only be set to either true or false. If the player is holding the mouse button and therefore activating the jetpack, we set it to true. Conversely if the player is not pressing the mouse button, jetpackActive is set to false.

This information is sent to the AdjustJetpack method where the emission rate of the jetpack is adjusted depending on whether the jetpack is active or not.

In your comment above you are passing a variable jetPack which is not the name we assign in the tutorial. If you have given your variable the name jetPack instead of jetpackActive, then this should still work, however, I like to name the variables something descriptive that will make it easier for me to understand and read the code later on. Additionally, the name jetPack is very close to the other variable jetpack which refers to our actual particle system. This potentially could further cause confusion.

I hope this reply helps, if there is anything else you need help with, please let me know!

Good luck with the rest of the tutorial and happy learning!

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!