How do I make an object blast way from a projectile?

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I am making a game in which you blast crates with a shotgun, but I have two problems:

    How do I make the crates shatter into pieces upon contact with the bullet,

    And how do I make those pieces fly away ( opposite from the direction of the bullet) at a reasonable speed to improve game feel and in general make the game better?.

    Thanks in advance for your help!,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The shattering into pieces part can be done by destroying the crate on collision with the bullet and creating crate bits at its former position.

    Overall you need to store the bullets angle on impact and just apply it +/- any random angle offset (to get a cone effect) to newly spawned crate pieces, which should have bullet behaviour. You can also randomly set their speed and accceleration (negative to slow down!) to give the impression some are heavier and some are lighter.

    Here's an example. The simple square cratebits sprites could be changed for actual fragments of your crate sprite, you could do multiple frames for the crate bits, disable the animation by setting the animation speed to 0, and upon creation assigning a random frame.

    https://www.dropbox.com/s/3vluoo10v8ncp ... .capx?dl=1

  • The shattering into pieces part can be done by destroying the crate on collision with the bullet and creating crate bits at its former position.

    Overall you need to store the bullets angle on impact and just apply it +/- any random angle offset (to get a cone effect) to newly spawned crate pieces, which should have bullet behaviour. You can also randomly set their speed and accceleration (negative to slow down!) to give the impression some are heavier and some are lighter.

    Here's an example. The simple square cratebits sprites could be changed for actual fragments of your crate sprite, you could do multiple frames for the crate bits, disable the animation by setting the animation speed to 0, and upon creation assigning a random frame.

    https://www.dropbox.com/s/3vluoo10v8ncp ... .capx?dl=1

    Thank you so damn much Pulstar! [Sorry for the minor swear :?]

    You've really helped me and I feel so damn awful for not replying after such a long time, here is the end result:

    Also I will be sure to add you onto the wall of credits <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">, You deserve a something.

  • No problem, always happy to help obliterate more pixelated crates

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