2D, random generating platforms algorithm

Hi, I have a mathematically/algorithm problem, I hope you can help me, to start off I must admit that math is not one of my strong sides :slight_smile:

I’m making a 2D game where the purpose is to jump up on randomly generated platforms.

My problem is to make sure the new platforms is above the last platform but not right on top since I’d like the player to be able to jump onto the platform.

I’d also like to make sure the new platform is horizontally in range of the last platform based on the player Rigidbody2D and player jump force and left/Right speed.
Each platform is held within a C# List platformsList

The player consist of a
Rigidbody 2D
-Mass 1, Linear Drag 0.5, Gravity Scale 0.6, Fixed Angle = Checked
Jump force = AddForce(new Vector2(0, 235)
I also got some variables containing how much to the left or right he jumps.

The game is made for mobile and tablets so I’m using Camera.main.ViewpointToWorldPoint to position my elements, where the x and y value is between 0-1f.

I’m thinking something like the algorithm might work this way.

First it makes a new X value and makes sure its not the exact same place as the platform before and makes sure the player can jump onto the new platform by calculating some physics based on RigidBody2D and the jump force and left/right speed.

Then it makes a new Y value and makes sure its over the last platform and makes sure its not right above the last platform including making sure the player can be on that platform and jump by calculating sprite size and jump force and then calculating the RigidBody 2D and jump force to make sure its possible to jump onto the platform.

Here is a picture of the game as of now with static positioned platforms just to give an idea how it is supposed to work.

I fail to see a question here. You have described a viable algorithm, how to solve your problem. Now implement it.

Look up physics equations, your answer will be there.
then what ever your equation is just make the platform less than the equations max.