- Home /
Weapon shooting mechanism problem.
AWP, and other secondary weapons are not working. It seems that the code does not execute the line:
playerShooter.Shoot(x);
I don't know why my whole function looks like this:
public void PerformShoot()
{
if (Input.GetMouseButton(0))
{
if (playerShooter.primaryWeaponOn() == true && playerShooter.ammoCurrentInt > 0)
{
switch (gameManager.GetComponent<GameManager>().primarySelected)
{
case "ak47":
playerShooter.Shoot(0.1f);
break;
case "m4a1":
playerShooter.Shoot(0.08f);
break;
case "scorpionvz":
playerShooter.Shoot(0.07f);
break;
case "ump45":
playerShooter.Shoot(0.11f);
break;
}
}
}
else if (Input.GetMouseButtonDown(0))
{
if (playerShooter.ammoCurrentInt > 0 && playerShooter.primaryWeaponOn() == true)
{
switch(gameManager.GetComponent<GameManager>().primarySelected)
{
case "awp":
playerShooter.Shoot(1.4f);
break;
}
}
else if (playerShooter.ammoCurrentIntSec > 0 && playerShooter.secondaryWeaponOn() == true)
{
switch (gameManager.GetComponent<GameManager>().secondarySelected)
{
case "m1911a":
playerShooter.Shoot(0.15f);
break;
case "makarov":
playerShooter.Shoot(0.1f);
break;
case "pm40":
playerShooter.Shoot(0.21f);
break;
}
}
}
}
Every variable is getting changed I checked it so it all should be good. I changed the code only in this class and the function is checking the variables in other classes which is another reason this should be working as I did not change anything in other classes. Some time ago this was working and now something happened.
Is it entering the different switch cases and if so what does this playerShooter.Shoot(x) method does?
Answer by betaFlux · Dec 31, 2018 at 12:49 AM
Does it help if you remove "else" from else if (Input.GetMouseButtonDown(0))
?
I fixed it already. There was a problem in another class. Not in this code.
Your answer
Follow this Question
Related Questions
A few problems with my weapon wheel script 1 Answer
Reload with keypress work bad! 0 Answers
shoot projectile from weapon 2 Answers
Coding a class swapping system 0 Answers
Any help with a weapon changing script? 2 Answers