Make objects move randomly, from any point, at any time

0 favourites
  • 5 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi guys been a long long time since i used C2 (probs in the R100 odd times) and alot has changes. Thinking of making a game but getting a little stumped. Im in need of a way to make an object spawn from a random location (outside of window), at a random time and to move across the screen. Any pointers? Cheers

  • I'd do it this way:

    First off, give the object that you're spawning some behavior for movement. I like bullet for this case.

    Every(round(random(1,10)) seconds ->

    System Create Object on layer 0 at

    X: round(random(ViewportLeft(0) + Sprite.Width,ViewportRight(0) - Sprite.Width))

    Y: -Sprite.Height

    Sprite -> Set Angle to 90

    I hope this helps. This will create sprites above the play area that then move down across the viewport.

  • Sounds good, but would be looking for sprites moving in from the sides too. I guess a bit like fruit ninja. Thanks for your help though ill get cracking with the above and try and add to it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use the same logic to make objects approach from all sides. Just change the X and Y spawn positions and sprite angle.

    X: ViewportRight(0) + Sprite.Width

    Y: round(random(ViewportTop(0) + Sprite.Width,ViewportBottom(0) - Sprite.Width)

    Sprite -> Set Angle to 180

    Then you'd have them approaching from the right side of the screen.

  • MrClifford try this demo

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