Help with obstacle positioning in autorunner.

0 favourites
  • 3 posts
From the Asset Store
Obstacle Impacts and Cartoon voices, will makes your game more funny!
  • I've got an autorunner game with obstacles and i'm having a little trouble with the positioning of the obstacles when they appear.

    Basically, i've set up my obstacles so that they appear at random points on platforms but most of the obstacles that appear are near the very beginning of the platform and very little of them actually appear near the end to mix things up, so it doesn't feel very random (hope that makes sense).

    I've provided a capx, so hopefully that will make my problem clearer. The code i'm using to sort the positioning of my obstacle is this -

    Box - Set position to (Block.X + Block.Width / random (10,1) , Block.Y)

    If i change the 'random (10,1)' portion to just 1, then all obstacles appear at the end of the platform and if i change to 10, then they'll end up at the beginning of the platform. So i thought using 'random (10,1)' would work but it's not as random as i hoped it would be.

    It could be something really simple that i'm missing but can anyone help?

    Thanks

  • I`m guessing this is what you where looking for?

    random position from tip to end? including middle? its just a math formula simple actually

    [attachment=0:2yvpa7hv][/attachment:2yvpa7hv] in future use instead of random(x,y,z) the action choose(x,y,z,s) its more accurate

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Cheers, this helps a lot Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)