Post by System Six Games on Jan 26, 2020 3:44:57 GMT
Hey everyone. I've seen a couple of threads of others looking for Selective Fire Mode scripts and I've created a version of that before I start researching on how to do burst firing modes. I've also created a Weapon RPM script that will apply a simple math calculation to the inserted int value and apply it to the Shoot Frequency in the Weapon Settings of the Shooter Weapon script. In this case, you'll have a correct and accurate Rounds Per Minute shot.
using Invector.vShooter;
using UnityEngine;
using UnityEngine.UI;
//Script created by Robert Faulk, System Six Games
public class SelectiveFire : MonoBehaviour
{
public vShooterWeapon weapon;
public Text selectiveFireText;
public bool selectiveFire;
public bool singleFire;
public bool fullAuto;
void Start()
{
selectiveFireText = GameObject.FindGameObjectWithTag("SFM").GetComponent<Text>();
if (weapon == null) weapon = gameObject.GetComponent<vShooterWeapon>();
}
void Update()
{
selectiveFireText = GameObject.FindGameObjectWithTag("SFM").GetComponent<Text>();
if (selectiveFire)
{
if (Input.GetKeyDown(KeyCode.X))
{
weapon.automaticWeapon = !weapon.automaticWeapon;
}
if (weapon.automaticWeapon == true)
selectiveFireText.text = "Full Auto";
if (weapon.automaticWeapon == false)
selectiveFireText.text = "Single Fire";
}
else if (singleFire)
{
weapon.automaticWeapon = false;
selectiveFireText.text = "Single Fire";
}
else if (fullAuto)
{
weapon.automaticWeapon = true;
selectiveFireText.text = "Full Auto";
}
else selectiveFire = true;
}
}
using UnityEngine;
using Invector.vShooter;
//Script created by Robert Faulk, System Six Games
public class WeaponRPM : MonoBehaviour
{
public vShooterWeapon weapon;
public float rpm;
void Start()
{
if (weapon == null) weapon = gameObject.GetComponentInParent<vShooterWeapon>();
RPMCheck();
}
void FixedUpdate()
{
RPMCheck();
}
void RPMCheck()
{
weapon.shootFrequency = (100f / (rpm / 60f)) * Time.deltaTime;
}
}
using UnityEngine;
using Invector.vShooter;
//Script created by Robert Faulk, System Six Games
public class WeaponRPM : MonoBehaviour
{
public vShooterWeapon weapon;
public float rpm;
void Start()
{
if (weapon == null) weapon = gameObject.GetComponentInParent<vShooterWeapon>();
RPMCheck();
}
void FixedUpdate()
{
RPMCheck();
}
void RPMCheck()
{
weapon.shootFrequency = (100f / (rpm / 60f)) * Time.deltaTime;
}
}
If there is something that you don't understand or would just like some clarification, please let me know.
using Invector.vShooter;
using UnityEngine;
using UnityEngine.UI;
//Script created by Robert Faulk, System Six Games
public class SelectiveFire : MonoBehaviour
{
public vShooterWeapon weapon;
public Text selectiveFireText;
public bool selectiveFire;
public bool singleFire;
public bool fullAuto;
void Start()
{
selectiveFireText = GameObject.FindGameObjectWithTag("SFM").GetComponent<Text>();
if (weapon == null) weapon = gameObject.GetComponent<vShooterWeapon>();
}
void Update()
{
selectiveFireText = GameObject.FindGameObjectWithTag("SFM").GetComponent<Text>();
if (selectiveFire)
{
if (Input.GetKeyDown(KeyCode.X))
{
weapon.automaticWeapon = !weapon.automaticWeapon;
}
if (weapon.automaticWeapon == true)
selectiveFireText.text = "Full Auto";
if (weapon.automaticWeapon == false)
selectiveFireText.text = "Single Fire";
}
else if (singleFire)
{
weapon.automaticWeapon = false;
selectiveFireText.text = "Single Fire";
}
else if (fullAuto)
{
weapon.automaticWeapon = true;
selectiveFireText.text = "Full Auto";
}
else selectiveFire = true;
}
}
using UnityEngine;
using Invector.vShooter;
//Script created by Robert Faulk, System Six Games
public class WeaponRPM : MonoBehaviour
{
public vShooterWeapon weapon;
public float rpm;
void Start()
{
if (weapon == null) weapon = gameObject.GetComponentInParent<vShooterWeapon>();
RPMCheck();
}
void FixedUpdate()
{
RPMCheck();
}
void RPMCheck()
{
weapon.shootFrequency = (100f / (rpm / 60f)) * Time.deltaTime;
}
}
using UnityEngine;
using Invector.vShooter;
//Script created by Robert Faulk, System Six Games
public class WeaponRPM : MonoBehaviour
{
public vShooterWeapon weapon;
public float rpm;
void Start()
{
if (weapon == null) weapon = gameObject.GetComponentInParent<vShooterWeapon>();
RPMCheck();
}
void FixedUpdate()
{
RPMCheck();
}
void RPMCheck()
{
weapon.shootFrequency = (100f / (rpm / 60f)) * Time.deltaTime;
}
}
If there is something that you don't understand or would just like some clarification, please let me know.