Hi all I’m new to game dev and c# a friend helping me learn started off creating a version of pong where you can change colours which effects collision like colour switch.
Anyway the issue I’m having is For the 2 pedals which are player 1 and 2 on a local machine is that the player one up and down key randomly don’t work until someone has scored (which resets the current scene with an updated score)
void Update()
{
if (Input.GetKey(upKey) && transform.position.y < topBounds)
{
transform.Translate(0f, speed*Time.deltaTime, 0);
Debug.Log("Gone to move player up");
}
else if (Input.GetKey(downKey) && transform.position.y > bottomBounds)
{
transform.Translate(0f, -speed*Time.deltaTime, 0);
Debug.Log("Gone to move player down");
//*********CODE ABOVE HERE THAT ISN'T WORKING*******
}
if (GameSettings.colourModeEnabled)
{
int currentColourIndex = (int)currentPongColour;
if (Input.GetKeyDown(nextColourKey))
{
currentPongColour = (PongColour)((currentColourIndex + 1) % 4);
}
else if (Input.GetKeyDown(previousColourKey))
{
currentPongColour = (PongColour)((currentColourIndex - 1 + 4) % 4);
}
pedalRenderer.material.color = Colour.ColourFromPongColour(currentPongColour);
}
}
I’ve checked the keys are assigned on the start of the game.
