|
Post by Jader on Oct 13, 2017 2:41:55 GMT
Hi everybody,
In the shooter template, there is an option to auto reload the ammo when shoot last bullet? and if not, how to do it via script?
Thanks
|
|
|
Post by sickscore on Oct 13, 2017 6:57:43 GMT
|
|
|
Post by Jader on Oct 13, 2017 14:12:11 GMT
|
|
|
Post by Jader on Oct 28, 2017 1:10:06 GMT
There's a problem sickscore. If you do not have ammo, collecting more does not reload automatically.
|
|
|
Post by sickscore on Oct 28, 2017 5:24:45 GMT
Good suggestion, will add this feature. I‘m away over the weekend, so you‘ll have to wait a few days ;-)
|
|
|
Post by Jader on Oct 28, 2017 17:41:21 GMT
No problem! Thanks
|
|
|
Post by Jader on Nov 10, 2017 0:58:07 GMT
|
|
|
Post by Jader on Feb 16, 2018 22:08:41 GMT
Hi sickscore, Do you think about my little problem? >.<
|
|
|
Post by projectonegames on Apr 3, 2018 17:17:02 GMT
After this section: ShooterManager.ReloadWeapon ();
Add this _canAutoReload = true;
Once it auto reloads the first time, the bool is set to false and it never auto reloads.
Also, within vShooterWeapon.cs, within this section, comment out this one line:
public virtual void ReloadEffect()
{
if (source)
{
//MLC This line was commented out because the explosion clip stops when auto reload happens source.Stop();
source.PlayOneShot(reloadClip);
}
if (projectileToHide != null)
StartCoroutine(ActiveHiddenProjectile(projectileToHideDelay));
onReload.Invoke();
}
|
|
|
Post by Jader on Apr 12, 2018 1:45:50 GMT
Thank you! I'll test soon
|
|
|
Post by projectonegames on Apr 12, 2018 2:29:59 GMT
I added this updated script to the vThirdPersonShooter or vThirdPersonController and changed vShooterWeapon.cs (comments above) Cheers
using System.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; using Invector; using Invector.vShooter; namespace Sickscore.InvectorAddons { [vClassHeader("AUTO-RELOAD MANAGER", true, "shooterIcon")] public class vAutoReloadManager : vMonoBehaviour { #region Variables protected vShooterManager ShooterManager; bool _canAutoReload = true; #endregion #region Main Methods void Awake () { // check/assign vShooterManager if (ShooterManager == null) { ShooterManager = GetComponent<vShooterManager> (); if (ShooterManager == null) Debug.LogError ("Couldn't find a vShooterManager component on your player!"); } // subscribe to events if (ShooterManager != null) { // reset auto-reload after reload event ShooterManager.onReloadWeapon.AddListener ((sw) => { _canAutoReload = true; }); } } void FixedUpdate () { if (ShooterManager == null || ShooterManager.rWeapon == null) return; // trigger reload, when ammo is depleted if (ShooterManager.rWeapon.ammoCount <= 0 && _canAutoReload) { _canAutoReload = false; ShooterManager.ReloadWeapon (); _canAutoReload = true; } } #endregion } }
|
|
|
Post by freakystudios on May 4, 2020 15:53:13 GMT
Hello bro i just used your auto reload script.I am using invector 1.3.2.I am getting this error!!
|
|
|
Post by spinifer on Dec 19, 2020 11:09:13 GMT
Hi, I am in serious trouble need help with auto-reload. Using Invector 1.3.2 When I am enabling auto reload in a gun, the ammo count becomes total count in UI and the gun will fire all those without any reload. When auto-reload is disabled: ibb.co/1nGSjmhWhen Auto reload is enabled: ibb.co/tzFRQwjBecause of these no auto reload is triggered because gun fire the total count if bullet not the mag size. Please Help !!!!!!
|
|