Problem Scripting simultaneous key presses

Hi everyone,
i’m stuck with this silly problem :

I have a fire button which the player must hold down and then i have 3 cases :
1-The player press Up only and then it fire forward
2-The player press Up and Left simulteously and then it fire Left
3-The player press Up and Right simulteously and then it fire Right

My problem is that as soon as my script get the Up key, it fires and doesn’t wait for the others keys…
I know there is no real simultaneous things in programmation.
Does someone have a solution for me? Or at least a clue?
I can delay the things with a timer but i hope there is a smarter way to achieve what i want.

Thanks

You’ll want a structure like this most likely (pseudo code):

if(Iput.getKeyDown('up')
{
    if(Input.GetKeyDown('left')
    {
        // whatever left
    }
    else if(Input.GetKeyDown('Right')
    {
        // whatever right
    }
    else
    {
        // whatever else
    }
}
1 Like

Thanks,
So simple i’m ashamed of my poor knowledge after so many years programming…

I take this opportunity to say there is an issue with multiple keys when the first is the space bar…
I had already read about this kind of problem on a forum and yes, it’s real !!!