How do i code a reload mechanic

  • How should i go about coding a reload mechanic in a top down shooter game? Any and all advice is appericiated. Answers and examples are appreciated even more as this project is for a class and time sensitive.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi theDeletr,

    I don't really know how others would build it up, but I'll try to explain how I usually do.

    Do you want to put ammo limit too ? I will consider that you don't for this simple explanation.

    So you need a variable for this. For example lets use a number variable called "ammo" wich is

    supposed to be the number of bullets in your gun, and that your gun is a classic

    pistol with 15 bullets in a loader. For example :

    IF player press SPACE

    IF "ammo" is greater than 0 Spawn Bullet

    Play sound "GunFire.ogg"

    Add to "ammo" -1

    Else

    IF "ammo" is equal to 0 Hero animation "Reloading"

    Play sound "GunReload.ogg"

    Wait 0.5 seconds

    Set "ammo" to 15.

    This makes your player reload if he press Space and that the loader is empty. The 0.5 wait command is

    the time needed to reload your gun.

    Please tell me if you don't understand what I mean, I think others might have a better way to do it.

  • thnx yours worked

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