I’ve been trying to implement shapeshifting mechanic to my game. And there are three current modes that you can switch between. But there seems to be a problem with the if checks im using or the way im using it. I asked some people but they told me to use state machines which i found really complicated for my simple code. But i would also like to hear your opinion.
Here’s the code:
` if (Input.GetKeyDown(KeyCode.Space))
{
if (normalMode == true || normalMode == false && speedMode == true && (heavyMode == false))
{
normalMode = false;
heavyMode = true;
sr.sprite = heavyForm;
speed = 7f;
rb.mass = 2f;
}
else if (normalMode == true && normalMode == false && (heavyMode == true && (speedForm == false)))
{
normalMode = false;
speedMode = true;
sr.sprite = speedForm;
speed = 15f;
rb.mass = 0.5f;
}
else
{
normalMode = true;
sr.sprite = normalForm;
speed = 10f;
rb.mass = 1f;
}
}
`
only the if and else statements work and the else if one doesn’t. Would be glad if someone helped me out.
Cramon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.