How Can I Attach A Sound To A Bullet Being Fired?

Discussion in 'How Can I...?' started by roy, Oct 23, 2016.

  1. roy

    roy Boxer

    Joined:
    Jul 23, 2016
    Messages:
    69
    Likes Received:
    27
    I'm sure I'm missing something obvious here. I have a character bullet that has a spawner so that the player is shooting continuously when playing. How can I have a sound that plays once when the bullet is fired?
     
  2. spicedbeangames

    spicedbeangames Miniboss Boxer

    Joined:
    Mar 31, 2016
    Messages:
    1,359
    Likes Received:
    575
    I had this problem when making my game.
    Firstly, I attached a sound to the 'shoot sound' attached to the character. But then I ran into several problems.

    1 - when firing a bullet it can actually kill stuff off the screen
    2 - It would be the same shooting sound for all weapons.
    3 - The sounds could also repeat if you die and restart(might be a bug but came across this)

    Solution
    To stop 1 from happening, I made a game object (Opacity 0) and large enough to cover the bullet spray area. I used a connection to attach FROM character to this object.
    Then, set the objects health to max 999999999. Set it to Enemy. When you character moves, this object moves too but will always remain ahead(if 2d shooter).

    I then made a bullet object that I set the bullet firing sound to play on DEATH.
    You then enter the shooting animation for your character or where you want the bullet to shoot from and drag in the bullet object.
    Set the bullet to character bullet and settings as desired for your game.
     
    playsgames6666, roy and JoeWilson like this.
  3. roy

    roy Boxer

    Joined:
    Jul 23, 2016
    Messages:
    69
    Likes Received:
    27
    Thank you for your answer and solutions. :) It's bit sad that these are the kind of hacks needed to do such a basic task. :(
     

Share This Page