Spawn random

  • Ok so I have a grid of 3x3 setup in 64x64, each block in the 3x3 grid has a "GridBlock Number" instance variable set too it, I am trying to spawn my player random on one of the grid blocks, I have tried quite a few different things like "choose(obj_playerGrid.GridBlock&1,2,3)" which had no effect other than setting the player on the top left corner. Is there anyway for my to set player position to object and than have it randomly select a GridBlock variable number say 0 - 8 and place the player correctly on that block ?

  • Are you saying it needs to pick 2 tiers of position, first which 3x3 grid then the block within it? That's not totally clear. Anyway, you would set a variable to floor(random(9)), which picks a random whole number from 0 - 8. Then you would spawn the player on the block where gridblock number = var. If you are choosing a 3x3 grid from the entire map before this then you would give each of the gridblock two variables, a main one where it decides which 3x3 block to go to initially and then use the floor random to pick 0-8 for individual block inside the grid. Something like grid 1, block 8 etc.

  • Yeah lol, I don't understand.

    Thanks for trying to help me though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There's a general example in C2 if you have it ... .capx?dl=0

    I only use C2 but it's the same in C3.

  • I was a bit late throwing this together but it's a slight bit different than what's been posted so I think it may be helpful in other ways. It's also a C2 file, but C3 should open it and it should work as a guide for what you want. ... .capx?dl=0

  • Thanks guys! the examples helped a ton!

    My only problem is that I have a specific image point setup for each grid block which is "1"

    All I need to know now is how to add that to the existing examples.

    Been trying a few different variations but I can't seem to add the image point to the position, always ends up telling me I cannot add a period. lol


  • The format is obj_playerGrid.ImagePointX(0) where the number in brackets is the ID of the imagepoint, 0 being the origin.

  • plinkie Thanks man! that's what I needed

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