How to make a reloading for a gun?

Report any bugs here or ask questions here!

How to make a reloading for a gun?

Postby Unreal engine 4 » 14 October 2020, 09:08

well, by saying "Reload" i meant the not the reloading animation, i meant how to make the trigger system so it should reload like m4a1 or glock
https://prnt.sc/wcyjpo
You know, you feel better if you know someone loves you. Even it if its a boy.

Unreal engine 4
Cyber Grub [25]
 
Posts: 29
Joined: 19 April 2020, 08:04

Re: How to make a reloading for a gun?

Postby Nyove » 14 October 2020, 15:13

Hey Unreal Engine 4,

First, use 'Call Trigger 'B' when Gun 'A' fired' trigger action, linking your gun to a trigger, let's call it trigger A.
-
Next, create a timer with 0 delay and enabled on start, targeting another trigger which creates a variable with the ammo count of your gun, let's call it ~ammoCount.
-
In trigger A, use trigger action 'Add value B to value of variable A', setting B with -1 to deduct 1 from the ~ammoCount variable each time the gun fired.
-
In the same trigger, add a trigger action after the deduction which checks if the ~ammoCount variable equals to 0.
'Continue trigger actions execution only if variable 'A' equals value 'B''
-
Below that trigger action, change the gun's fire rate to 0 as well as forcing it to spawn 0 projectile.
'Change Gun 'A' speed multiplier to value 'B''
'Force Gun 'A' spawn 'B' projectiles per shot'
-
After that, activate a timer (disabled on start, delay depends on how long you want the gun to reload for).
-
This timer executes another trigger which sets the gun's speed multipler and spawn projectiles back to 1 (or whatever you want).

Best regards,
Nyove
Proud to be part of something meaningful.
Need any assistance? Join the PB2 discord server at https://discord.com/invite/Bhe9rNz or raise a support ticket at https://www.plazmaburst2.com/support

Contact me on discord for quickest reply possible.

User avatar
Nyove
Falkok [250]
 
Posts: 255
Joined: 7 July 2016, 10:26
Location: Cicada 3301

Re: How to make a reloading for a gun?

Postby xElijah » 14 October 2020, 15:22

Nyove wrote:Below that trigger action, change the gun's fire rate to 0 as well as forcing it to spawn 0 projectile

Is it really necessary to set gun's projectile count to 0? I tested it and it seems to work fine just by setting gun's speed multiplier to 0.

To add to what Nyove said, this system doesn't work properly in multiplayer because PB2 is a client-side game.
User avatar
xElijah
Usurpation Soldier [50]
 
Posts: 96
Joined: 3 October 2020, 15:43

Re: How to make a reloading for a gun?

Postby Nyove » 14 October 2020, 15:42

Hey xElijah,

Actually no - my bad, I only have the habit of forcing it to spawn 0 projectiles because if you set speed multiplier to 0 at the very start of the map, the gun will be able to shoot once. (It's reloaded at the start of the game.)

In terms of MP, damage wise since PB2 calculate damage based on the client of the attacker, it can actually work. However, visual-wise it will not be synced. The gun may seem to be shooting in other player's screen while the attacker is actually reloading.

To fix this issue implement syncing for the variable ~ammoCount. Preferable to use the trigger action that syncs based on the minimum value.

Best regards,
Nyove
Proud to be part of something meaningful.
Need any assistance? Join the PB2 discord server at https://discord.com/invite/Bhe9rNz or raise a support ticket at https://www.plazmaburst2.com/support

Contact me on discord for quickest reply possible.

User avatar
Nyove
Falkok [250]
 
Posts: 255
Joined: 7 July 2016, 10:26
Location: Cicada 3301


Return to Bug Reporting, Help & Support

Who is online

Users browsing this forum: No registered users