How do I Move and stop object on a random timer

  • I have these levers in my game that I would like to move down randomly and I also need them to stop randomly. On start of the game the levers start in their top positions. throughout the game I would like the levers to individually move down at different times (so even if lever_1 moves lever_2 and lever_3 don't have to move.). I also would like the levers to individually stop their downward movement at random times too.

    Example: Every 4-9 seconds the lever should move down for 2-4 seconds then it should stop. That should repeat until the lever reaches the bottom.

    I have attached the capx that I have been working on and the progress thus far. I haven't started with the random timing mechanic because I don't know where to start exactly.

    capx instruction:

    move sprite with arrows

    move sprite over place holder and press up and down arrows to move lever

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can just make an instance variable and subtract dt from it, and when it's <=1 reset to random(n) + x where x is the base time, and random(n) is the variability.

  • Thanks, I'll give that a try today.

  • I know it has been a while but I took some time off from the project im working on but now I'm back to work. I'm still having an issue with that post I entered below. I'm still a beginner when it comes to some parts of construct so I'm not too sure what you are taking about exactly, but I am eager to learn.

    To be completely honest I understand everything until instant variable after that I'm lost. I'm not even sure what object I should create the instance variable on. Please help.

  • Ok, well I spent most of today working on this part of my project. I have the mechanic working and I learnt a couple of things today. I created a condition that asked the system to check every choose (2,3,4,5) and set the objects y to it's current position + choose(11,15,16,19). I wished I could the object to have a gradually transition but I test it out a cpl of times today and I am satisfied with this part of the game.

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