Weapon switching.

0 favourites
  • 8 posts
From the Asset Store
JBoB Sound Studio AAA Quality Sound Effect "Weapon Master" Pack contain royalty-free stock sound effects.
  • I have two guns set up in their own Group, First one is active from start, the second is activated after picking up a new gun. Works great but when i go to fire the second gun, one bullet from Group one also fires a single bullet on first trigger tap. Not sure how to fix this.

  • Depending on how your events are set up... first thing to check is make sure group one is disabled when you enable group two?

  • I tried that, bullets from weapon one still fire from weapon two when Group one is Deactivated. Also I would like to add more than two weapons to the game, so I am not sure if Groups are the thing to go with or not. I am using an Array to swap initially swap between weapons once a second gun is picked up by clicking on the d-pad.

  • Here's a picture of my Event Sheet.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am having issue uploading the pic of my event sheet, so i just copied the text for now.

    + obj_player_mask: On collision with oNewGun

    -> System: Set group "Weapon Two" Activated

    -> oNewGun: Destroy

    + Gamepad: On gamepad 0 D-pad down pressed

    ----+ System: [X] Weap_num ≥ Arr_Weapons.Width - 1

    -----> System: Add 1 to Weap_num

    ----+ System: Else

    -----> System: Set Weap_num to 0

    [Weapon One]

    ----+ System: Weap_num = 0

    -----> obj_gun: Set animation to "ID_MACHINEGUN" (play from beginning)

    --------+ Gamepad: Gamepad 0 Right shoulder trigger is down

    --------+ System: Every 0.16 seconds

    --------+ obj_gun: Is animation "ID_MACHINEGUN" playing

    ---------> obj_gun: Spawn obj_bullet on layer "Player" (image point "Bullet")

    [Weapon Two]

    ----+ System: Weap_num = 1

    -----> obj_gun: Set animation to "ID_MINIGUN" (play from beginning)

    --------+ Gamepad: Gamepad 0 Right shoulder trigger is down

    --------+ System: Every 0.12 seconds

    --------+ obj_gun: Is animation "ID_MINIGUN" playing

    ---------> obj_gun: Spawn oAI_Bullet on layer "Player" (image point "Bullet")

  • My two cents... Forget groups. Create a function for firing weapons, a variable for current weapon and an array or JSON with the attributes for all weapons (rate of fire, aimation ID, etc). When firing a weapon use the variable to load the correct array or JSON values for that weapon.

    Here's an example.

    • A, S, D, W to move robot.
    • Mouse to point cannon.
    • Left Mouse Down to shoot.
    • 1, 2 and 3 to select weapons.

    Hope this helps...

    Cheers!

  • Thanks! I'll definitely give that a try this weekend.

  • I used Variables to control which weapon is active. 0-5, each weapon pick up is determined by its corresponding variable, works great.

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