I have a control scheme for different mechanics. It is setup so you can do a shot or pass with left click and right click, then when you hold control it changes the way the shot or pass moves. They have also have a charge that determines how powerful they are based off mousehold time. If the charge fills up it will also complete the shot or pass function. However when I press the control key, the shots are always the same power even though I can see the value changing on the right because its a public float. And also the function to fire/pass when the meter is filled up doesn’t work with the “control” modifier. Since the non-control functions and meters work properly I wont paste them in. The chipshot and lobpass function are basically the same code just without the modifier in the if statements. Any help would be appreciated.
VOIDS:
void Shoot()
{
Ball.AddForce((PlayerCamera.transform.forward) * ShotPowerCurrent, ForceMode.Impulse);
Ball.AddForce((PlayerCamera.transform.up) * ShotHeight, ForceMode.Impulse);
}
void ChipShot()
{
Ball.AddForce((PlayerBody.transform.forward) * ChipShotPower, ForceMode.Impulse);
Ball.AddForce((PlayerBody.transform.up) * ChipShotHeight, ForceMode.Impulse);
}
void Pass()
{
Ball.AddForce((PlayerBody.transform.forward) * PassPowerCurrent, ForceMode.Impulse);
Ball.AddForce((PlayerBody.transform.up) * PassHeight, ForceMode.Impulse);
}
void LobPass()
{
Ball.AddForce((PlayerBody.transform.forward) * LobPassPower, ForceMode.Impulse);
Ball.AddForce((PlayerBody.transform.up) * LobPassHeight, ForceMode.Impulse);
}
UPDATE:
// LobChipModifier
if (Input.GetKeyDown("left ctrl"))
{
LobChipModifier = true;
}
if (Input.GetKeyUp("left ctrl"))
{
LobChipModifier = false;
}
if (LobChipModifier)
{
ChipShotPower = ShotPowerCurrent / 1.25f;
ChipShotHeight = ChipShotPower * 1.5f;
LobPassPower = PassPowerCurrent * 1f;
LobPassHeight = LobPassPower * 1f;
}
// Shooting
if (LobChipModifier && Triggered && Input.GetMouseButtonUp(0))
{
ChipShot();
}
if (LobChipModifier && Triggered && ShotPowerCurrent >= ShotPowerMax)
{
ChipShot();
}
// Passing
if (LobChipModifier && Triggered && PassPowerCurrent >= PassPowerMax)
{
LobPass();
}
if (LobChipModifier && Triggered && Input.GetMouseButtonUp(1))
{
LobPass();
}
}
}