How do I Create explosions on random parts of object

  • so i have a object - let's say it's a huuuge box.

    it's collision is a square. now if i hit from the left with bullet it will hit "on collision with .. spawn explosion.. bla bla" , that explosion explodes exactly where it was hit. If i do it from up, left or bottom, same thing.

    how can i make that explosion appear randomly inside that square? (or prolong a few milliseconds of bullet flight and then destroy it - causing random explosion)

  • You could mess around with events, but this behaviour is just perfect for that sort of thing:

  • that looks pretty good for spawning random, but what if i want my bullet to fly a bit more... ? i've attached a picture as example.

  • There are many ways one can do that.

  • Give your bullet some sort of a life gauge instance variable and subtract from it when overlapping the object it hits. Spawn explosions every .x seconds, destroy bullet when it's life is over or under a limit.

  • Try this demo

  • An unnecessary overly complicated example capx, but perhaps it can provide you with some ideas...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thnx guys, i will try somebodys idea, i can't try your capx's because i use only stable constructs (r195 atm), but i will check them out when next stable (probably r200) is out.

    Somebody - i need that value to be random - if my sprite is x in length and y in height, how can i get a random value for the duration of bullet not to fly outside on the other side and stop inside that sprite? (i need it randomly, your timer should work, but how do i determine timer's range of values? (from x,y and bullet speed)? )

  • saiyadjin m you can always open a capx with an older build if you fiddle with the caproj file. To do that you need to:

    1) unrar a capx file to its components (each capx is actually a zipped project folder structure).

    2) Open the caproj file with a text editor

    3) Find the <saved-with-version>19800</saved-with-version> field and change the 5 digit number accordingly (for version r195 type 19500)

    4) save the caproj and run it. It should open just fine, unless some feature that was introduced on a later version is being used.

  • didn't know that, thanx

    edit: both examples are exactly what i needed, thank you guys!

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