Question by
jafboy · Jul 26, 2020 at 04:03 PM ·
instantiateprefabinstantiate prefabinput managerholding
how can I instantiate bullet prefabs continuously while holding the left mouse button? ,how can I instantiate bullet prefabs continuously while holding the left click button?
I have a bullet prefab that I want to spawn the hole time while holding down the left mouse button and stop spawning when the button is released. However, I am using the new input master system on unity. anyone can help me with that?
my input checker for shooting:
controls.player.Shoot.performed += ctx => shootOn();
controls.player.Shoot.canceled += ctx => shootOff();
the methods that I am using with the input:
void shootOn()
{
Instantiate(bullet, firePoint.position, firePoint.rotation);
shoot = true;
animator.SetBool("IsShooting", shoot);
}
void shootOff()
{
shoot = false;
animator.SetBool("IsShooting", shoot);
}
Comment