Procedural Line Generation

So, little bit of why I’m asking this… I’m 15 years old, almost 16 and I’m looking at Game Development as a career and I thought it’d be best to start with Unity. I’ve used Scratch before (and still do for school) and love using that, however, it doesn’t offer much as it’s primly 2D and doesn’t really offer a scrolling background as an option, so… I havn’t doe coding as such before, and I haven’t found it particularly easy so far.

I’m looking at making a game which requires a line with an ever-changing direction (N, W, or E (not South because then you’d be going backwards and I’m looking at making it more like Doodle Jump, you always go up)). I figured a slow acting procedural generated line would be my best bet. I’m wondering if anyone could link me to some code for such a request as I’ve now been searching for two days.
I’ve got my other code sorted out, as I found a basic tutorial (which tbh I didn’t find many of) which gave me my code for my other sprite so that was good.

Thanks in advance for any replies be that links or explanations etc. Loving the Unity community as I’ve seen it so far :slight_smile:

Welcome!

I’m not entirely sure what you’re asking. Or rather, I’m not sure what you’re envisioning and how that applies to your question.

One of the things that always gets said to people with post counts of 1 is: “Have you gone through the tutorials yet?” It can be a bit tedious when you already have some programming experience and want to skip straight to the good stuff, but going through all the motions will go a long way to making you an effective user of the engine.

If I’m interpreting correctly, you’re picturing something like this:


Where a continuous line gets drawn to the screen, creating flat sections the player will have to jump to in order to keep advancing.

There are quite a few ways you can do this, I’d think, but the way I’d probably try first is using a set of prefabs. One for vertical pieces, and one each for horizontal pieces going left and right. Make sure the anchors of the sprites are set appropriately with the vertical anchor being at the bottom, while the left has its anchor on the right, and vice versa for the right one.

When you start drawing a piece, you’ll go in its appropriate direction for a randomized amount of time (within a range) and then stop. Keep track of the point you stop at, and begin drawing a right or left (random) piece from that point, again for a random amount of time. Continue forever.

The right and left pieces should have colliders attached to them, but they should be disabled initially until the player’s position is above them. Make sure the colliders stretch with the image. Ensure the camera pans up with the currently drawing piece, and have a trigger area that follows along just beneath the camera’s viewable area, that if the player enters, triggers a game over.

That should be enough to get you started, I’d think. If I’m way off on what you’re actually asking, I apologize. Feel free to provide more info to get this on the right track!

2 Likes

Hahahaha, damn. I knew I shouldn’t have used Doodle Jump as an example xD Other than the platforms, yes that’s what I’m wanting. Thank you very much for spending your tim to answer my question. No, I haven’t gone through the tutorials, I got rather overwhelmed by them and couldn’t find the patience to read or watch through. I was hoping game would be that you have the follow the line and hat if your sprite was to leave the line, then you lose (take your pictures but put the circle over the line and that’s what I had in mind, then your sprite size would gradually get smaller and speeds would increase), but now that I think of that, it’s been done in other ways (minus my two mechanics in the last set of brackets)…that’s a shame. However, there is a plus side to all this! I do like your interpretation and I think I might try to develop something like that… So again, thank you very much, Schneider :slight_smile:

Happy to help! Some responses in bulleted form:

  • Reconsider the tutorials. Especially since your excuse was being overwhelmed and lacking patience. Making games is often overwhelming and will try your patience. Learn to overcome these challenges early, or you’ll continue to struggle (and may end up even quitting) game development altogether.
  • Just because an idea has been done is no reason to not do it still! Especially if your iteration adds or changes something in a way that can make it play very differently.
  • Don’t get too caught up in planning this early on. For simple games like this (which is a great choice for a first Unity project, by the way), try to get to prototyping early. Find the fun, or if it’s not there, find out how to get it there or move on to the next project quickly. Why not build both versions (what I described and what you had in mind) and see which one you and others like more?!
  • Do the tutorials! :slight_smile:
1 Like

Very compelling points, you have. Thanks for everything, Schneider, I’ll try both :slight_smile:
(P.S. I’m currently watching a tutorial ;))

1 Like

Yep, I agree with @Schneider21 ; if you lack the patience to get through the tutorials, you should pick a different career path. :slight_smile:

Also, as for drawing lines, the easiest way to do this is with the Vectrosity plug-in. It’s $30, but worth every penny. Explain to your parents that this will help you focus on learning a useful and growing career (I can dig up some stats if you want on how many more computer science jobs there are than graduates right now), keep you off the streets, build skills that will help you ace your AP tests and get more scholarships for college, etc. If you want to really impress them, do this in the form of a well-written 1- or 2-page grant proposal, explaining exactly why you need the $30 and what benefits you’ll get from it.

(I’m a parent of a teenager myself, and this would certainly be the quickest way to get me to open my wallet!)

Have fun, and good luck!

  • Joe

P.S. Oh yeah, and another way to draw lines and other stuff, if you want something a little more similar to Scratch, is to use my PixelSurface asset… which is only $20. :slight_smile:

3 Likes

Thanks for your response, Joe. I don’t like spending money and I think I’ll just try make do with I have, but I’ll definitely take your suggestion into consideration :slight_smile: