Hey all, I'm having a little bit of trouble with this movement script. Basically what I've done is added a variable for movement speed (as variables automatically have an XYZ value) and given them a default value of zero. After that I added an ent_move function with relative movement as my move variable.

Then I made a while loop that changes move_var's y value to 20 while the W key is pressed which moves it forward. But when I try to copy the while loop and assign it to a different key (so that I can make it move in all directions) it either only moves forward when I press W (as if ignoring the new while loop), or stops the movement working all-together.

I simply can not figure out what I should do. I would be deeply appreciative if you could help me sort this out. Here is my script so far (the one that works):

Code:
var move_var;

action PlayerAct
{
	move_var.x = 0;
	move_var.y = 0;
	move_var.z = 0;
	move_mode = GLIDE;
	while(1)
	{
		ent_move (move_var, nullvector);
		wait(1);
	while(!key_w)
	{
		move_var.y = 20;
		wait(1);
	}
	}
	}


And here is where it doesn't work:
Code:
var move_var;

action PlayerAct
{
	move_var.x = 0;
	move_var.y = 0;
	move_var.z = 0;
	move_mode = GLIDE;
	while(1)
	{
		ent_move (move_var, nullvector);
		wait(1);
	while(!key_w)
	{
		move_var.y = 20;
		wait(1);
	}
	
	while(!key_s)
	{
		move_var.y = -20; //This one doesn't work, and stops the other one from working as well.
		wait(1);
	}
	}
	}