Hello everyone, I'm kind of new to programming and new to Galaxy scripting so bare with me if the solution seems obvious.
I'm trying to rotate a unit (Hellion) and have it move in the direction it's facing by modifying certain functions in rrowland's WASD library (thank you rrowland :) ) however there is a bug that I just can't figure out.
From what I understand; lets say the unit (Hellion) is facing 90 degrees, the code should return 90 degrees and move the unit in that direction when I press 'W'.
What actually happens is the Hellion continuously rotates counterclockwise on the spot. I think I'm missing some key information but it doesn't make any sense. But at least it's rotating :3
I'm a bit confused right now. I don't understand what's the purpose of this function in combination with what you want.
I've looked at rrowland's library a while ago and I remember it's using bits to save the movement keys, so I got that. But looking at your modification it seems that the only thing you want to do is to get a unit's facing. Why modify that function?
If I remember correctly the original purpose of this function was not to return a unit's facing angle, but to turn the bit number into a degree angle.
The function returns an angle based on the key pressed so I'm using it to return the angle of the unit at any given time during it's rotation while a key is pressed. So A button would return (UnitFacing + 2) and D button would return (UnitFacing - 2)
lv_tempBits=libWASD_gv_wASDState[lp_player];if(lv_tempBits==0x0001){//W pressed//W is pressed}elseif(lv_tempBits==0x0010){//A pressedreturnUnitGetFacing(libWASD_gv_controlledUnits[lp_player])+2;}elseif(lv_tempBits==0x0100){//S pressed//S is pressed}elseif(lv_tempBits==0x1000){//D pressedreturnUnitGetFacing(libWASD_gv_controlledUnits[lp_player])-2;}return0;
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello everyone, I'm kind of new to programming and new to Galaxy scripting so bare with me if the solution seems obvious.
I'm trying to rotate a unit (Hellion) and have it move in the direction it's facing by modifying certain functions in rrowland's WASD library (thank you rrowland :) ) however there is a bug that I just can't figure out.
Code Snippet
My modifications:
lv_tempAngle = UnitGetFacing (libWASD_gv_controlledUnits[lp_player]);
return lv_tempAngle;
Function: getWASDAngle
From what I understand; lets say the unit (Hellion) is facing 90 degrees, the code should return 90 degrees and move the unit in that direction when I press 'W'.
What actually happens is the Hellion continuously rotates counterclockwise on the spot. I think I'm missing some key information but it doesn't make any sense. But at least it's rotating :3
I'm a bit confused right now. I don't understand what's the purpose of this function in combination with what you want.
I've looked at rrowland's library a while ago and I remember it's using bits to save the movement keys, so I got that. But looking at your modification it seems that the only thing you want to do is to get a unit's facing. Why modify that function?
If I remember correctly the original purpose of this function was not to return a unit's facing angle, but to turn the bit number into a degree angle.
The function returns an angle based on the key pressed so I'm using it to return the angle of the unit at any given time during it's rotation while a key is pressed. So A button would return (UnitFacing + 2) and D button would return (UnitFacing - 2)
So doesn't this solve your problem: