How do I set position of an object to random instance?

  • I'm trying to make a roguelike shooter and have the level generator implemented but can't spawn the player. I have red markers in the corners of each room and in the middle and want the player to start at a randomly chosen marker on the map. How do I randomly choose an instance and use it to spawn my player?

    I've tried this:

    On start of layout | Player > Set position to (Marker.X, Marker.Y)

    Pick a random Marker instance

    But it hasn't worked. I guess a better thing to ask would be how to reference the marker that was chosen?

  • That's correct, let's see a screenshot of how you set it up. The order is on start of layout, sub event : pick random instance of marker > action : set player to marker.

    If you have the actual event set up correctly then the problem could be with a number of things, maybe the markers haven't been created yet when you go to pick one etc.

  • That's correct, let's see a screenshot of how you set it up. The order is on start of layout, sub event : pick random instance of marker > action : set player to marker.

    If you have the actual event set up correctly then the problem could be with a number of things, maybe the markers haven't been created yet when you go to pick one etc.

    i.imgur.com/CBkqoWB.jpg

    I don't think that it is because the markers aren't created because the game only knows its done generating after the markers have been created.

  • What's 'On completed', AJAX? Do you know for sure it has completed, did you try other actions to verify?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On completed is from the dungeon generator plugin I'm using made by rexrainbow

  • Check the following:

    Layout is linked to the proper event sheet

    Player sprite is created properly

    Markers are created properly

    Check visibiity of the player sprite (layers, zindex, visibility)

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