How do I spawn randomly off screen

0 favourites
  • 4 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • How do I make it so a certain object will spawn at a completely random location off screen, then move towards the player? I can probably figure out the moving part but not the spawning. If I pick a random location completely sometimes it spawns on the screen, and sometimes it spawns so far away it might as well not be there! How do I limit this kind of thing?

  • One way to do it is to spawn it at the player(or some other on-screen location), then use the "move at angle" action with a random angle to move it off screen in a random direction.

  • One way to do it is to spawn it at the player(or some other on-screen location), then use the "move at angle" action with a random angle to move it off screen in a random direction.

    Eh that kind of works, but theres 2 problem with it:

    1) No matter the speed, the spawned object shows up on screen for like a frame, which is noticeable.

    2) the spawned object is meant to be destroy when it touched the object its spawning from, i get set variables that toggle when it's spawned so that it isn't destroyed, but if anther one touches the object thats spawning them while one is being spawned, it wont be destroyed, thus creating a bug.

    EDIT

    I managed to fix that first problem just by moving to different layers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > One way to do it is to spawn it at the player(or some other on-screen location), then use the "move at angle" action with a random angle to move it off screen in a random direction.

    >

    Eh that kind of works, but theres 2 problem with it:

    1) No matter the speed, the spawned object shows up on screen for like a frame, which is noticeable.

    2) the spawned object is meant to be destroy when it touched the object its spawning from, i get set variables that toggle when it's spawned so that it isn't destroyed, but if anther one touches the object thats spawning them while one is being spawned, it wont be destroyed, thus creating a bug.

    EDIT

    I managed to fix that first problem just by moving to different layers

    As long as you create it and move it in the same event, it should in a single frame, and it should not do any collision tests until after it has moved. Here is a capx file with an example

    also here is another capx file with a small game i made using 2 different methods of spawning objects off-screen

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